Skip to content

Commit

Permalink
Merge pull request #18739 from Veykril/push-ntpvvqnnovtn
Browse files Browse the repository at this point in the history
fix: Don't trigger paren wrapping typing handler after idents
  • Loading branch information
Veykril authored Dec 22, 2024
2 parents ca17481 + a7f3265 commit 2f33e85
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/ide/src/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1091,6 +1094,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(
Expand Down

0 comments on commit 2f33e85

Please sign in to comment.