mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
fix: Don't add braces to 'if' completion in match guard position
When the cursor is in a match arm, but before the fat arrow (=>) token, don't add braces when autocompleting "if". fixes #12823
This commit is contained in:
parent
0b131bc78e
commit
13c83f90ac
4 changed files with 88 additions and 1 deletions
|
@ -21,6 +21,7 @@ pub(crate) fn complete_expr_path(
|
|||
ref is_func_update,
|
||||
ref innermost_ret_ty,
|
||||
ref impl_,
|
||||
in_match_guard,
|
||||
..
|
||||
}: &ExprCtx,
|
||||
) {
|
||||
|
@ -195,7 +196,11 @@ pub(crate) fn complete_expr_path(
|
|||
add_keyword("while", "while $1 {\n $0\n}");
|
||||
add_keyword("while let", "while let $1 = $2 {\n $0\n}");
|
||||
add_keyword("loop", "loop {\n $0\n}");
|
||||
add_keyword("if", "if $1 {\n $0\n}");
|
||||
if in_match_guard {
|
||||
add_keyword("if", "if $0");
|
||||
} else {
|
||||
add_keyword("if", "if $1 {\n $0\n}");
|
||||
}
|
||||
add_keyword("if let", "if let $1 = $2 {\n $0\n}");
|
||||
add_keyword("for", "for $1 in $2 {\n $0\n}");
|
||||
add_keyword("true", "true");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue