From 822abb3e62440b3c2235c502a2af33172c8a2e10 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 30 Dec 2018 18:08:17 +0300 Subject: semies after break&continue --- .../ra_analysis/src/completion/complete_keyword.rs | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs index 2869e67e0..b2486104a 100644 --- a/crates/ra_analysis/src/completion/complete_keyword.rs +++ b/crates/ra_analysis/src/completion/complete_keyword.rs @@ -32,8 +32,13 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte acc.add(keyword("else if", "else if $0 {}")); } if is_in_loop_body(ctx.leaf) { - acc.add(keyword("continue", "continue")); - acc.add(keyword("break", "break")); + if ctx.can_be_stmt { + acc.add(keyword("continue", "continue;")); + acc.add(keyword("break", "break;")); + } else { + acc.add(keyword("continue", "continue")); + acc.add(keyword("break", "break")); + } } acc.add_all(complete_return(fn_def, ctx.can_be_stmt)); } @@ -201,8 +206,8 @@ mod tests { match "match $0 {}" while "while $0 {}" loop "loop {$0}" - continue "continue" - break "break" + continue "continue;" + break "break;" return "return $0;" "#, ); @@ -222,4 +227,28 @@ mod tests { "#, ); } + + #[test] + fn no_semi_after_break_continue_in_expr() { + check_keyword_completion( + r" + fn f() { + loop { + match () { + () => br<|> + } + } + } + ", + r#" + if "if $0 {}" + match "match $0 {}" + while "while $0 {}" + loop "loop {$0}" + continue "continue" + break "break" + return "return" + "#, + ) + } } -- cgit v1.2.3