Fix complete semicolon in array expression

Example
---
```rust
fn foo() {}
fn bar() {
    let _ = [fo$0];
}
```

**Before this PR**

```rust
fn foo() {}
fn bar() {
    let _ = [foo();$0];
}
```

**After this PR**

```rust
fn foo() {}
fn bar() {
    let _ = [foo()$0];
}
```
This commit is contained in:
A4-Tacks 2026-01-04 20:54:19 +08:00
parent 854f1f8db1
commit f091a8acad
No known key found for this signature in database
GPG key ID: 9E63F956E66DD9C7
2 changed files with 23 additions and 1 deletions

View file

@ -821,7 +821,10 @@ impl<'db> CompletionContext<'db> {
CompleteSemicolon::DoNotComplete
} else if let Some(term_node) =
sema.token_ancestors_with_macros(token.clone()).find(|node| {
matches!(node.kind(), BLOCK_EXPR | MATCH_ARM | CLOSURE_EXPR | ARG_LIST | PAREN_EXPR)
matches!(
node.kind(),
BLOCK_EXPR | MATCH_ARM | CLOSURE_EXPR | ARG_LIST | PAREN_EXPR | ARRAY_EXPR
)
})
{
let next_token = iter::successors(token.next_token(), |it| it.next_token())

View file

@ -905,6 +905,25 @@ fn baz(_: impl FnOnce()) {}
fn bar() {
baz(foo()$0);
}
"#,
);
}
#[test]
fn no_semicolon_in_array() {
check_edit(
r#"foo"#,
r#"
fn foo() {}
fn bar() {
let _ = [fo$0];
}
"#,
r#"
fn foo() {}
fn bar() {
let _ = [foo()$0];
}
"#,
);
}