aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 16:25:30 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 16:25:30 +0000
commit942c45a31c4ffcf544362c8068360cac49627032 (patch)
treeabc22976f9512050e184ec8649826f99b3bb477e /crates/ra_analysis/src/completion
parent0f95d8523e0646aac8fb69c61f7b0d7a8efe42bb (diff)
parent822abb3e62440b3c2235c502a2af33172c8a2e10 (diff)
Merge #374
374: add semi after break&continue r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r--crates/ra_analysis/src/completion/complete_keyword.rs37
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}