fix: Fix completions not working after attributes

This commit is contained in:
Lukas Wirth 2022-05-23 17:20:42 +02:00
parent db9930b986
commit 2aa22730f1
3 changed files with 11 additions and 11 deletions

View File

@ -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(_))

View File

@ -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<Immedi
} else {
return None
},
ast::Attr(_) => 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);
}
}

View File

@ -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
"#]],