diff options
author | Lukas Wirth <[email protected]> | 2021-06-16 16:56:04 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-16 20:51:20 +0100 |
commit | 9ea6ee6b2785da02ff1963fbbc2eea340450905c (patch) | |
tree | 6ee0a69dc2e44eb04c1f7e3841a423da4b2bf4ca /crates/ide_completion/src/completions/snippet.rs | |
parent | 1a8f76a224aff472cf29bab828f313c19e31eb02 (diff) |
Don't show incorrect completions after unsafe or visiblity node
Diffstat (limited to 'crates/ide_completion/src/completions/snippet.rs')
-rw-r--r-- | crates/ide_completion/src/completions/snippet.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ide_completion/src/completions/snippet.rs b/crates/ide_completion/src/completions/snippet.rs index 5560f1acf..4e64a0090 100644 --- a/crates/ide_completion/src/completions/snippet.rs +++ b/crates/ide_completion/src/completions/snippet.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | //! This file provides snippet completions, like `pd` => `eprintln!(...)`. | 1 | //! This file provides snippet completions, like `pd` => `eprintln!(...)`. |
2 | 2 | ||
3 | use ide_db::helpers::SnippetCap; | 3 | use ide_db::helpers::SnippetCap; |
4 | use syntax::T; | ||
4 | 5 | ||
5 | use crate::{ | 6 | use crate::{ |
6 | context::PathCompletionContext, item::Builder, CompletionContext, CompletionItem, | 7 | context::PathCompletionContext, item::Builder, CompletionContext, CompletionItem, |
@@ -35,9 +36,13 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte | |||
35 | } | 36 | } |
36 | 37 | ||
37 | pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) { | 38 | pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) { |
38 | if !ctx.expects_item() { | 39 | if !ctx.expects_item() || ctx.previous_token_is(T![unsafe]) { |
39 | return; | 40 | return; |
40 | } | 41 | } |
42 | if ctx.has_visibility_prev_sibling() { | ||
43 | return; // technically we could do some of these snippet completions if we were to put the | ||
44 | // attributes before the vis node. | ||
45 | } | ||
41 | let cap = match ctx.config.snippet_cap { | 46 | let cap = match ctx.config.snippet_cap { |
42 | Some(it) => it, | 47 | Some(it) => it, |
43 | None => return, | 48 | None => return, |