From b211c5814e994a411095e4392d804d692d58d43b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 May 2020 16:48:50 +0200 Subject: Remove false positive attr compleitons --- .../src/completion/complete_qualified_path.rs | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/completion/complete_qualified_path.rs') diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index aa56a5cd8..d9ea92ef8 100644 --- a/crates/ra_ide/src/completion/complete_qualified_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs @@ -2,16 +2,21 @@ use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; use ra_syntax::AstNode; +use rustc_hash::FxHashSet; use test_utils::tested_by; use crate::completion::{CompletionContext, Completions}; -use rustc_hash::FxHashSet; pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { let path = match &ctx.path_prefix { Some(path) => path.clone(), - _ => return, + None => return, }; + + if ctx.attribute_under_caret.is_some() { + return; + } + let scope = ctx.scope(); let context_module = scope.module(); @@ -1325,4 +1330,18 @@ mod tests { "### ); } + + #[test] + fn dont_complete_attr() { + assert_debug_snapshot!( + do_reference_completion( + r" + mod foo { pub struct Foo; } + #[foo::<|>] + fn f() {} + " + ), + @r###"[]"### + ) + } } -- cgit v1.2.3