diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/completion/complete_keyword.rs | 37 |
1 files changed, 33 insertions, 4 deletions
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 | |||
32 | acc.add(keyword("else if", "else if $0 {}")); | 32 | acc.add(keyword("else if", "else if $0 {}")); |
33 | } | 33 | } |
34 | if is_in_loop_body(ctx.leaf) { | 34 | if is_in_loop_body(ctx.leaf) { |
35 | acc.add(keyword("continue", "continue")); | 35 | if ctx.can_be_stmt { |
36 | acc.add(keyword("break", "break")); | 36 | acc.add(keyword("continue", "continue;")); |
37 | acc.add(keyword("break", "break;")); | ||
38 | } else { | ||
39 | acc.add(keyword("continue", "continue")); | ||
40 | acc.add(keyword("break", "break")); | ||
41 | } | ||
37 | } | 42 | } |
38 | acc.add_all(complete_return(fn_def, ctx.can_be_stmt)); | 43 | acc.add_all(complete_return(fn_def, ctx.can_be_stmt)); |
39 | } | 44 | } |
@@ -201,8 +206,8 @@ mod tests { | |||
201 | match "match $0 {}" | 206 | match "match $0 {}" |
202 | while "while $0 {}" | 207 | while "while $0 {}" |
203 | loop "loop {$0}" | 208 | loop "loop {$0}" |
204 | continue "continue" | 209 | continue "continue;" |
205 | break "break" | 210 | break "break;" |
206 | return "return $0;" | 211 | return "return $0;" |
207 | "#, | 212 | "#, |
208 | ); | 213 | ); |
@@ -222,4 +227,28 @@ mod tests { | |||
222 | "#, | 227 | "#, |
223 | ); | 228 | ); |
224 | } | 229 | } |
230 | |||
231 | #[test] | ||
232 | fn no_semi_after_break_continue_in_expr() { | ||
233 | check_keyword_completion( | ||
234 | r" | ||
235 | fn f() { | ||
236 | loop { | ||
237 | match () { | ||
238 | () => br<|> | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | ", | ||
243 | r#" | ||
244 | if "if $0 {}" | ||
245 | match "match $0 {}" | ||
246 | while "while $0 {}" | ||
247 | loop "loop {$0}" | ||
248 | continue "continue" | ||
249 | break "break" | ||
250 | return "return" | ||
251 | "#, | ||
252 | ) | ||
253 | } | ||
225 | } | 254 | } |