mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge pull request #18739 from Veykril/push-ntpvvqnnovtn
fix: Don't trigger paren wrapping typing handler after idents
This commit is contained in:
commit
2f33e85f56
1 changed files with 19 additions and 0 deletions
|
@ -174,6 +174,9 @@ fn on_delimited_node_typed(
|
||||||
kinds: &[fn(SyntaxKind) -> bool],
|
kinds: &[fn(SyntaxKind) -> bool],
|
||||||
) -> Option<TextEdit> {
|
) -> Option<TextEdit> {
|
||||||
let t = reparsed.syntax().token_at_offset(offset).right_biased()?;
|
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
|
let (filter, node) = t
|
||||||
.parent_ancestors()
|
.parent_ancestors()
|
||||||
.take_while(|n| n.text_range().start() == offset)
|
.take_while(|n| n.text_range().start() == offset)
|
||||||
|
@ -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]
|
#[test]
|
||||||
fn adds_closing_parenthesis_for_pat() {
|
fn adds_closing_parenthesis_for_pat() {
|
||||||
type_char(
|
type_char(
|
||||||
|
|
Loading…
Reference in a new issue