diff options
Diffstat (limited to 'crates/libeditor/src')
-rw-r--r-- | crates/libeditor/src/completion.rs | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/crates/libeditor/src/completion.rs b/crates/libeditor/src/completion.rs index be37fb6bf..b296f6fd5 100644 --- a/crates/libeditor/src/completion.rs +++ b/crates/libeditor/src/completion.rs | |||
@@ -62,16 +62,16 @@ fn is_single_segment(name_ref: ast::NameRef) -> bool { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | fn complete_expr_keywords(file: &File, fn_def: ast::FnDef, name_ref: ast::NameRef, acc: &mut Vec<CompletionItem>) { | 64 | fn complete_expr_keywords(file: &File, fn_def: ast::FnDef, name_ref: ast::NameRef, acc: &mut Vec<CompletionItem>) { |
65 | acc.push(keyword("if", "if $0 { }")); | 65 | acc.push(keyword("if", "if $0 {}")); |
66 | acc.push(keyword("match", "match $0 { }")); | 66 | acc.push(keyword("match", "match $0 {}")); |
67 | acc.push(keyword("while", "while $0 { }")); | 67 | acc.push(keyword("while", "while $0 {}")); |
68 | acc.push(keyword("loop", "loop {$0}")); | 68 | acc.push(keyword("loop", "loop {$0}")); |
69 | 69 | ||
70 | if let Some(off) = name_ref.syntax().range().start().checked_sub(2.into()) { | 70 | if let Some(off) = name_ref.syntax().range().start().checked_sub(2.into()) { |
71 | if let Some(if_expr) = find_node_at_offset::<ast::IfExpr>(file.syntax(), off) { | 71 | if let Some(if_expr) = find_node_at_offset::<ast::IfExpr>(file.syntax(), off) { |
72 | if if_expr.syntax().range().end() < name_ref.syntax().range().start() { | 72 | if if_expr.syntax().range().end() < name_ref.syntax().range().start() { |
73 | acc.push(keyword("else", "else {$0}")); | 73 | acc.push(keyword("else", "else {$0}")); |
74 | acc.push(keyword("else if", "else if $0 { }")); | 74 | acc.push(keyword("else if", "else if $0 {}")); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
@@ -276,9 +276,9 @@ mod tests { | |||
276 | fn quux() { | 276 | fn quux() { |
277 | <|> | 277 | <|> |
278 | } | 278 | } |
279 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 279 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
280 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 280 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
281 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 281 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
282 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 282 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
283 | CompletionItem { name: "return", snippet: Some("return") }]"#); | 283 | CompletionItem { name: "return", snippet: Some("return") }]"#); |
284 | } | 284 | } |
@@ -291,12 +291,12 @@ mod tests { | |||
291 | () | 291 | () |
292 | } <|> | 292 | } <|> |
293 | } | 293 | } |
294 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 294 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
295 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 295 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
296 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 296 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
297 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 297 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
298 | CompletionItem { name: "else", snippet: Some("else {$0}") }, | 298 | CompletionItem { name: "else", snippet: Some("else {$0}") }, |
299 | CompletionItem { name: "else if", snippet: Some("else if $0 { }") }, | 299 | CompletionItem { name: "else if", snippet: Some("else if $0 {}") }, |
300 | CompletionItem { name: "return", snippet: Some("return") }]"#); | 300 | CompletionItem { name: "return", snippet: Some("return") }]"#); |
301 | } | 301 | } |
302 | 302 | ||
@@ -307,9 +307,9 @@ mod tests { | |||
307 | <|> | 307 | <|> |
308 | 92 | 308 | 92 |
309 | } | 309 | } |
310 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 310 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
311 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 311 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
312 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 312 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
313 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 313 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
314 | CompletionItem { name: "return", snippet: Some("return $0;") }]"#); | 314 | CompletionItem { name: "return", snippet: Some("return $0;") }]"#); |
315 | check_snippet_completion(r" | 315 | check_snippet_completion(r" |
@@ -317,9 +317,9 @@ mod tests { | |||
317 | <|> | 317 | <|> |
318 | 92 | 318 | 92 |
319 | } | 319 | } |
320 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 320 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
321 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 321 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
322 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 322 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
323 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 323 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
324 | CompletionItem { name: "return", snippet: Some("return;") }]"#); | 324 | CompletionItem { name: "return", snippet: Some("return;") }]"#); |
325 | } | 325 | } |
@@ -332,9 +332,9 @@ mod tests { | |||
332 | () => <|> | 332 | () => <|> |
333 | } | 333 | } |
334 | } | 334 | } |
335 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 335 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
336 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 336 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
337 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 337 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
338 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 338 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
339 | CompletionItem { name: "return", snippet: Some("return $0") }]"#); | 339 | CompletionItem { name: "return", snippet: Some("return $0") }]"#); |
340 | } | 340 | } |
@@ -345,9 +345,9 @@ mod tests { | |||
345 | fn quux() -> i32 { | 345 | fn quux() -> i32 { |
346 | loop { <|> } | 346 | loop { <|> } |
347 | } | 347 | } |
348 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 348 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
349 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 349 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
350 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 350 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
351 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 351 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
352 | CompletionItem { name: "continue", snippet: Some("continue") }, | 352 | CompletionItem { name: "continue", snippet: Some("continue") }, |
353 | CompletionItem { name: "break", snippet: Some("break") }, | 353 | CompletionItem { name: "break", snippet: Some("break") }, |
@@ -356,9 +356,9 @@ mod tests { | |||
356 | fn quux() -> i32 { | 356 | fn quux() -> i32 { |
357 | loop { || { <|> } } | 357 | loop { || { <|> } } |
358 | } | 358 | } |
359 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 { }") }, | 359 | ", r#"[CompletionItem { name: "if", snippet: Some("if $0 {}") }, |
360 | CompletionItem { name: "match", snippet: Some("match $0 { }") }, | 360 | CompletionItem { name: "match", snippet: Some("match $0 {}") }, |
361 | CompletionItem { name: "while", snippet: Some("while $0 { }") }, | 361 | CompletionItem { name: "while", snippet: Some("while $0 {}") }, |
362 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, | 362 | CompletionItem { name: "loop", snippet: Some("loop {$0}") }, |
363 | CompletionItem { name: "return", snippet: Some("return $0") }]"#); | 363 | CompletionItem { name: "return", snippet: Some("return $0") }]"#); |
364 | } | 364 | } |