Skip to content

Commit

Permalink
Auto merge of #12360 - Veykril:completion, r=Veykril
Browse files Browse the repository at this point in the history
fix: Fix completions not working after attributes

Closes #12259
  • Loading branch information
bors committed May 23, 2022
2 parents 8e8aa7b + 2aa2273 commit 402dba8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 1 addition & 4 deletions crates/ide-completion/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_))
Expand Down
7 changes: 0 additions & 7 deletions crates/ide-completion/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub(crate) enum ImmediatePrevSibling {
TraitDefName,
ImplDefType,
Visibility,
Attribute,
}

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -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,
}
};
Expand Down Expand Up @@ -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);
}
}
10 changes: 10 additions & 0 deletions crates/ide-completion/src/tests/item_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
"#]],
Expand Down

0 comments on commit 402dba8

Please sign in to comment.