Skip to content

Commit 3f26c57

Browse files
committed
don't complete top level attrs inside nested attrs and add better labels #4890
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
1 parent 9aad07d commit 3f26c57

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

crates/ra_ide/src/completion/complete_attribute.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,18 @@ pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
2222
}
2323
(_, Some(ast::AttrInput::TokenTree(token_tree))) => {
2424
let token_tree_str = token_tree.to_string();
25-
complete_attribute_start(
26-
acc,
27-
ctx,
28-
attribute,
29-
token_tree_str.starts_with('(') && token_tree_str.ends_with(')'),
30-
)
25+
let nested = token_tree_str.starts_with('(') && token_tree_str.ends_with(')');
26+
27+
if !nested {
28+
complete_attribute_start(acc, ctx, attribute);
29+
}
3130
}
32-
_ => complete_attribute_start(acc, ctx, attribute, false),
31+
_ => complete_attribute_start(acc, ctx, attribute),
3332
}
3433
Some(())
3534
}
3635

37-
fn complete_attribute_start(
38-
acc: &mut Completions,
39-
ctx: &CompletionContext,
40-
attribute: &ast::Attr,
41-
nested: bool,
42-
) {
36+
fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attribute: &ast::Attr) {
4337
for attr_completion in ATTRIBUTES {
4438
let mut item = CompletionItem::new(
4539
CompletionKind::Attribute,
@@ -56,9 +50,7 @@ fn complete_attribute_start(
5650
}
5751

5852
if attribute.kind() == ast::AttrKind::Inner || !attr_completion.should_be_inner {
59-
if (nested && attr_completion.should_be_inner) || !nested {
60-
acc.add(item);
61-
}
53+
acc.add(item);
6254
}
6355
}
6456
}

0 commit comments

Comments
 (0)