From 46514448b740b82e4f5f9cf742c6f8c6caec1d38 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 13 Nov 2020 22:31:41 +0200 Subject: Tweak the search limits a bit --- crates/completion/src/completions/magic.rs | 4 +++- crates/ide_db/src/imports_locator.rs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/completion/src/completions/magic.rs b/crates/completion/src/completions/magic.rs index ef0fc27ba..2ac6f94a9 100644 --- a/crates/completion/src/completions/magic.rs +++ b/crates/completion/src/completions/magic.rs @@ -13,11 +13,13 @@ use crate::{ use super::Completions; +// TODO kb reuse auto_import assist approach to add trait completion // TODO kb add a setting toggle for this feature? pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { return None; } + let _p = profile::span("complete_magic"); let current_module = ctx.scope.module()?; let anchor = ctx.name_ref_syntax.as_ref()?; let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; @@ -25,7 +27,7 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> let potential_import_name = ctx.token.to_string(); let possible_imports = - imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name) + imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400) .filter_map(|import_candidate| { Some(match import_candidate { Either::Left(module_def) => ( diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index 71fb7207b..1b21f76ac 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs @@ -35,6 +35,7 @@ pub fn find_similar_imports<'a>( sema: &Semantics<'a, RootDatabase>, krate: Crate, name_to_import: &str, + limit: usize, ) -> impl Iterator> { let _p = profile::span("find_similar_imports"); find_imports( @@ -42,10 +43,10 @@ pub fn find_similar_imports<'a>( krate, { let mut local_query = LocalImportablesQuery::new(name_to_import.to_string()); - local_query.limit(40); + local_query.limit(limit); local_query }, - ExternalImportablesQuery::new(name_to_import).limit(40), + ExternalImportablesQuery::new(name_to_import).limit(limit), ) } -- cgit v1.2.3