From 3f26c5758d7beb1207ed187b71fe9fa6fcaa03ec Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Thu, 18 Jun 2020 21:31:49 +0200 Subject: 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> --- crates/ra_ide/src/completion/complete_attribute.rs | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs index 814d7109d..9c7ccc950 100644 --- a/crates/ra_ide/src/completion/complete_attribute.rs +++ b/crates/ra_ide/src/completion/complete_attribute.rs @@ -22,24 +22,18 @@ pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) } (_, Some(ast::AttrInput::TokenTree(token_tree))) => { let token_tree_str = token_tree.to_string(); - complete_attribute_start( - acc, - ctx, - attribute, - token_tree_str.starts_with('(') && token_tree_str.ends_with(')'), - ) + let nested = token_tree_str.starts_with('(') && token_tree_str.ends_with(')'); + + if !nested { + complete_attribute_start(acc, ctx, attribute); + } } - _ => complete_attribute_start(acc, ctx, attribute, false), + _ => complete_attribute_start(acc, ctx, attribute), } Some(()) } -fn complete_attribute_start( - acc: &mut Completions, - ctx: &CompletionContext, - attribute: &ast::Attr, - nested: bool, -) { +fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attribute: &ast::Attr) { for attr_completion in ATTRIBUTES { let mut item = CompletionItem::new( CompletionKind::Attribute, @@ -56,9 +50,7 @@ fn complete_attribute_start( } if attribute.kind() == ast::AttrKind::Inner || !attr_completion.should_be_inner { - if (nested && attr_completion.should_be_inner) || !nested { - acc.add(item); - } + acc.add(item); } } } -- cgit v1.2.3