From 05ec824ab70139f9400ad15408ccfe6bc6ccb9fe Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 3 Jul 2021 22:11:01 +0200 Subject: [PATCH] Don't show an import per namespace in auto_import --- crates/ide_assists/src/handlers/auto_import.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index accc345fc625..36c0d370defd 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -84,11 +84,13 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel}; // ``` pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let (import_assets, syntax_under_caret) = find_importable_node(ctx)?; - let proposed_imports = + let mut proposed_imports = import_assets.search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind); if proposed_imports.is_empty() { return None; } + // we aren't interested in different namespaces + proposed_imports.dedup_by(|a, b| a.import_path == b.import_path); let range = ctx.sema.original_range(&syntax_under_caret).range; let group_label = group_label(import_assets.import_candidate());