Skip to content

Commit 3613526

Browse files
authored
Merge pull request rust-lang#18739 from Veykril/push-ntpvvqnnovtn
fix: Don't trigger paren wrapping typing handler after idents
2 parents 36455e9 + 15206e4 commit 3613526

File tree

1 file changed

+19
-0
lines changed
  • src/tools/rust-analyzer/crates/ide/src

1 file changed

+19
-0
lines changed

src/tools/rust-analyzer/crates/ide/src/typing.rs

+19
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ fn on_delimited_node_typed(
174174
kinds: &[fn(SyntaxKind) -> bool],
175175
) -> Option<TextEdit> {
176176
let t = reparsed.syntax().token_at_offset(offset).right_biased()?;
177+
if t.prev_token().map_or(false, |t| t.kind().is_any_identifier()) {
178+
return None;
179+
}
177180
let (filter, node) = t
178181
.parent_ancestors()
179182
.take_while(|n| n.text_range().start() == offset)
@@ -1091,6 +1094,22 @@ fn f() {
10911094
);
10921095
}
10931096

1097+
#[test]
1098+
fn preceding_whitespace_is_significant_for_closing_brackets() {
1099+
type_char_noop(
1100+
'(',
1101+
r#"
1102+
fn f() { a.b$0if true {} }
1103+
"#,
1104+
);
1105+
type_char_noop(
1106+
'(',
1107+
r#"
1108+
fn f() { foo$0{} }
1109+
"#,
1110+
);
1111+
}
1112+
10941113
#[test]
10951114
fn adds_closing_parenthesis_for_pat() {
10961115
type_char(

0 commit comments

Comments
 (0)