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:
parent
854f1f8db1
commit
f091a8acad
2 changed files with 23 additions and 1 deletions
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue