diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-12-22 11:22:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-22 11:22:56 +0000 |
| commit | 36135264a6176cfc2091ae7a31c849a6391fcbe5 (patch) | |
| tree | 418ba6b3aa4e012f7412835b039fefdf1fcd88fa /src/tools/rust-analyzer | |
| parent | 36455e9557f4c5c7af97916ab15d6bf9b090ace8 (diff) | |
| parent | 15206e49426da94980e738673c77084b5e62c8cd (diff) | |
| download | rust-36135264a6176cfc2091ae7a31c849a6391fcbe5.tar.gz rust-36135264a6176cfc2091ae7a31c849a6391fcbe5.zip | |
Merge pull request #18739 from Veykril/push-ntpvvqnnovtn
fix: Don't trigger paren wrapping typing handler after idents
Diffstat (limited to 'src/tools/rust-analyzer')
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide/src/typing.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/typing.rs b/src/tools/rust-analyzer/crates/ide/src/typing.rs index 3d9146cc4c7..d37318ff457 100644 --- a/src/tools/rust-analyzer/crates/ide/src/typing.rs +++ b/src/tools/rust-analyzer/crates/ide/src/typing.rs @@ -174,6 +174,9 @@ fn on_delimited_node_typed( kinds: &[fn(SyntaxKind) -> bool], ) -> Option<TextEdit> { let t = reparsed.syntax().token_at_offset(offset).right_biased()?; + if t.prev_token().map_or(false, |t| t.kind().is_any_identifier()) { + return None; + } let (filter, node) = t .parent_ancestors() .take_while(|n| n.text_range().start() == offset) @@ -1092,6 +1095,22 @@ fn f() { } #[test] + fn preceding_whitespace_is_significant_for_closing_brackets() { + type_char_noop( + '(', + r#" +fn f() { a.b$0if true {} } +"#, + ); + type_char_noop( + '(', + r#" +fn f() { foo$0{} } +"#, + ); + } + + #[test] fn adds_closing_parenthesis_for_pat() { type_char( '(', |
