aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-11-13 20:31:41 +0000
committerKirill Bulatov <[email protected]>2020-11-16 19:19:06 +0000
commit46514448b740b82e4f5f9cf742c6f8c6caec1d38 (patch)
tree3c0b226594c9a18e8d49d738d5c419a09cee25db
parent1598740292c29613ef2b384a82de3a2735bc5566 (diff)
Tweak the search limits a bit
-rw-r--r--crates/completion/src/completions/magic.rs4
-rw-r--r--crates/ide_db/src/imports_locator.rs5
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::{
13 13
14use super::Completions; 14use super::Completions;
15 15
16// TODO kb reuse auto_import assist approach to add trait completion
16// TODO kb add a setting toggle for this feature? 17// TODO kb add a setting toggle for this feature?
17pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 18pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
18 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { 19 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
19 return None; 20 return None;
20 } 21 }
22 let _p = profile::span("complete_magic");
21 let current_module = ctx.scope.module()?; 23 let current_module = ctx.scope.module()?;
22 let anchor = ctx.name_ref_syntax.as_ref()?; 24 let anchor = ctx.name_ref_syntax.as_ref()?;
23 let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; 25 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) ->
25 let potential_import_name = ctx.token.to_string(); 27 let potential_import_name = ctx.token.to_string();
26 28
27 let possible_imports = 29 let possible_imports =
28 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name) 30 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400)
29 .filter_map(|import_candidate| { 31 .filter_map(|import_candidate| {
30 Some(match import_candidate { 32 Some(match import_candidate {
31 Either::Left(module_def) => ( 33 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>(
35 sema: &Semantics<'a, RootDatabase>, 35 sema: &Semantics<'a, RootDatabase>,
36 krate: Crate, 36 krate: Crate,
37 name_to_import: &str, 37 name_to_import: &str,
38 limit: usize,
38) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { 39) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> {
39 let _p = profile::span("find_similar_imports"); 40 let _p = profile::span("find_similar_imports");
40 find_imports( 41 find_imports(
@@ -42,10 +43,10 @@ pub fn find_similar_imports<'a>(
42 krate, 43 krate,
43 { 44 {
44 let mut local_query = LocalImportablesQuery::new(name_to_import.to_string()); 45 let mut local_query = LocalImportablesQuery::new(name_to_import.to_string());
45 local_query.limit(40); 46 local_query.limit(limit);
46 local_query 47 local_query
47 }, 48 },
48 ExternalImportablesQuery::new(name_to_import).limit(40), 49 ExternalImportablesQuery::new(name_to_import).limit(limit),
49 ) 50 )
50} 51}
51 52