From 2aa22730f137ec68f9a045d7caa7323da8720835 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 23 May 2022 17:20:42 +0200 Subject: [PATCH] fix: Fix completions not working after attributes --- crates/ide-completion/src/context.rs | 5 +---- crates/ide-completion/src/patterns.rs | 7 ------- crates/ide-completion/src/tests/item_list.rs | 10 ++++++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs index e51ae0dc3b5d..2942a52010c3 100644 --- a/crates/ide-completion/src/context.rs +++ b/crates/ide-completion/src/context.rs @@ -371,10 +371,7 @@ impl<'a> CompletionContext<'a> { // FIXME: This shouldn't exist pub(crate) fn is_path_disallowed(&self) -> bool { self.previous_token_is(T![unsafe]) - || matches!( - self.prev_sibling, - Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility) - ) + || matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility)) || matches!( self.completion_location, Some(ImmediateLocation::RecordPat(_) | ImmediateLocation::RecordExpr(_)) diff --git a/crates/ide-completion/src/patterns.rs b/crates/ide-completion/src/patterns.rs index 07b2ac4297f3..b2bf895743fc 100644 --- a/crates/ide-completion/src/patterns.rs +++ b/crates/ide-completion/src/patterns.rs @@ -24,7 +24,6 @@ pub(crate) enum ImmediatePrevSibling { TraitDefName, ImplDefType, Visibility, - Attribute, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -124,7 +123,6 @@ pub(crate) fn determine_prev_sibling(name_like: &ast::NameLike) -> Option ImmediatePrevSibling::Attribute, _ => return None, } }; @@ -484,9 +482,4 @@ mod tests { fn test_vis_prev_sibling() { check_prev_sibling(r"pub w$0", ImmediatePrevSibling::Visibility); } - - #[test] - fn test_attr_prev_sibling() { - check_prev_sibling(r"#[attr] w$0", ImmediatePrevSibling::Attribute); - } } diff --git a/crates/ide-completion/src/tests/item_list.rs b/crates/ide-completion/src/tests/item_list.rs index f3208129364c..d03a4fd5cd13 100644 --- a/crates/ide-completion/src/tests/item_list.rs +++ b/crates/ide-completion/src/tests/item_list.rs @@ -78,7 +78,10 @@ fn in_item_list_after_attr() { check( r#"#[attr] $0"#, expect![[r#" + ma makro!(…) macro_rules! makro + md module kw const + kw crate:: kw enum kw extern kw fn @@ -87,8 +90,10 @@ fn in_item_list_after_attr() { kw pub kw pub(crate) kw pub(super) + kw self:: kw static kw struct + kw super:: kw trait kw type kw union @@ -184,11 +189,16 @@ fn in_impl_assoc_item_list_after_attr() { check( r#"impl Struct { #[attr] $0 }"#, expect![[r#" + ma makro!(…) macro_rules! makro + md module kw const + kw crate:: kw fn kw pub kw pub(crate) kw pub(super) + kw self:: + kw super:: kw type kw unsafe "#]],