9477: fix: Don't show an import per namespace in auto_import r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9113
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-07-03 20:13:14 +00:00 committed by GitHub
commit e73328f22a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());