7593: fix: add for keyword in completion #7588 r=lnicola a=gowrizrh

Fixes #7588
bors r+

Co-authored-by: Gowri <gowri.sankar@aligent.com.au>
Co-authored-by: Gowri <gowrizrh@gmail.com>
This commit is contained in:
bors[bot] 2021-02-08 08:00:41 +00:00 committed by GitHub
commit a996b381bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,6 +88,7 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
add_keyword(ctx, acc, "loop", "loop {$0}");
add_keyword(ctx, acc, "if", "if $0 {}");
add_keyword(ctx, acc, "if let", "if let $1 = $0 {}");
add_keyword(ctx, acc, "for", "for $1 in $0 {}");
}
if ctx.if_is_prev || ctx.block_expr_parent {
@ -258,6 +259,7 @@ mod tests {
kw loop
kw if
kw if let
kw for
kw let
kw mod
kw const
@ -284,6 +286,7 @@ mod tests {
kw loop
kw if
kw if let
kw for
kw let
kw mod
kw const
@ -310,6 +313,7 @@ mod tests {
kw loop
kw if
kw if let
kw for
kw let
kw else
kw else if
@ -343,6 +347,7 @@ fn quux() -> i32 {
kw loop
kw if
kw if let
kw for
kw unsafe
kw return
"#]],
@ -391,6 +396,7 @@ fn quux() -> i32 {
kw loop
kw if
kw if let
kw for
kw let
kw mod
kw const
@ -549,6 +555,7 @@ pub mod future {
kw loop
kw if
kw if let
kw for
kw return
"#]],
)
@ -607,6 +614,7 @@ fn foo() {
kw loop
kw if
kw if let
kw for
kw return
"#]],
);