aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_snippet.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-23 07:45:08 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-23 07:45:08 +0000
commit1d7baef0e96d6c1db2d049f3770588f07b8d739f (patch)
treeebfe1de5f52c088f20ffd3d1c591514e844307e0 /crates/ra_ide_api/src/completion/complete_snippet.rs
parent488326ffa74bea2773eed9c1849e9d3b9eac9b2d (diff)
parent13d2fd32ab5df598496c6abbf46591ff05cd3def (diff)
Merge #603
603: fix completion bugs r=gfreezy a=gfreezy The result is as below. before: ![image](https://user-images.githubusercontent.com/510012/51483467-0f641400-1dd4-11e9-9921-ef21d15cc343.png) after: ![image](https://user-images.githubusercontent.com/510012/51483433-fb201700-1dd3-11e9-9730-c2a5d3dd5f5a.png) Co-authored-by: gfreezy <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_snippet.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_snippet.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs
index d3344b865..d1cea7375 100644
--- a/crates/ra_ide_api/src/completion/complete_snippet.rs
+++ b/crates/ra_ide_api/src/completion/complete_snippet.rs
@@ -10,6 +10,7 @@ pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
10 if !(ctx.is_trivial_path && ctx.function_syntax.is_some()) { 10 if !(ctx.is_trivial_path && ctx.function_syntax.is_some()) {
11 return; 11 return;
12 } 12 }
13
13 snippet(ctx, "pd", "eprintln!(\"$0 = {:?}\", $0);").add_to(acc); 14 snippet(ctx, "pd", "eprintln!(\"$0 = {:?}\", $0);").add_to(acc);
14 snippet(ctx, "ppd", "eprintln!(\"$0 = {:#?}\", $0);").add_to(acc); 15 snippet(ctx, "ppd", "eprintln!(\"$0 = {:#?}\", $0);").add_to(acc);
15} 16}
@@ -48,6 +49,18 @@ mod tests {
48 } 49 }
49 50
50 #[test] 51 #[test]
52 fn should_not_complete_snippets_in_path() {
53 check_snippet_completion(
54 "should_not_complete_snippets_in_path",
55 r"fn foo(x: i32) { ::foo<|> }",
56 );
57 check_snippet_completion(
58 "should_not_complete_snippets_in_path2",
59 r"fn foo(x: i32) { ::<|> }",
60 );
61 }
62
63 #[test]
51 fn completes_snippets_in_items() { 64 fn completes_snippets_in_items() {
52 check_snippet_completion( 65 check_snippet_completion(
53 "snippets_in_items", 66 "snippets_in_items",