Auto merge of #12642 - weirdsmiley:master, r=Veykril

fix: deduplicate cfg completions

cfg completions are duplicated if they are set with multiple values.
This patch deduplicates them.

fixes: [#12623](https://github.com/rust-lang/rust-analyzer/issues/12623)
This commit is contained in:
bors 2022-06-27 12:16:06 +00:00
commit f6c0bf8f09

View File

@ -3,6 +3,7 @@
use std::iter;
use ide_db::SymbolKind;
use itertools::Itertools;
use syntax::SyntaxKind;
use crate::{completions::Completions, context::CompletionContext, CompletionItem};
@ -34,7 +35,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
acc.add(item.build());
}),
None => ctx.krate.potential_cfg(ctx.db).get_cfg_keys().cloned().for_each(|s| {
None => ctx.krate.potential_cfg(ctx.db).get_cfg_keys().cloned().unique().for_each(|s| {
let item = CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), s);
acc.add(item.build());
}),