From 0e48cd0c3c712cea0267476de974012b2b05b508 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 28 Dec 2020 11:41:08 +0200 Subject: Draft the module exclusion in modules --- crates/completion/src/completions/unqualified_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index d09849752..3d72a08b4 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -135,7 +135,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() ctx.krate?, Some(100), &potential_import_name, - true, + false, ) .filter_map(|import_candidate| { Some(match import_candidate { -- cgit v1.2.3 From c4995cfbd5b265c02d3038d72b8a022cde5f7040 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 28 Dec 2020 14:24:13 +0200 Subject: Better query api and fuzzy search --- crates/completion/src/completions/unqualified_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 3d72a08b4..d09849752 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -135,7 +135,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() ctx.krate?, Some(100), &potential_import_name, - false, + true, ) .filter_map(|import_candidate| { Some(match import_candidate { -- cgit v1.2.3 From e4c3f753d23752a9fbb01bdf1cd92a8cb1f6681e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 28 Dec 2020 14:54:31 +0200 Subject: Add docs and optimisations --- crates/completion/src/completions/unqualified_path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index d09849752..aefbdb163 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -101,8 +101,8 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T // // .Fuzzy search details // -// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only -// (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers. +// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the names only +// (i.e. in `HashMap` in the `std::collections::HashMap` path). // // .Merge Behavior // -- cgit v1.2.3 From 77b4a1c5ef594ddd78c77dd8bb05fba14b99cc9f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 28 Dec 2020 16:19:51 +0200 Subject: Tweak the fuzzy search limits --- crates/completion/src/completions/unqualified_path.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index aefbdb163..59f950189 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -103,6 +103,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T // // To avoid an excessive amount of the results returned, completion input is checked for inclusion in the names only // (i.e. in `HashMap` in the `std::collections::HashMap` path). +// For the same reasons, avoids searching for any imports for inputs with their length less that 2 symbols. // // .Merge Behavior // @@ -126,6 +127,10 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() let _p = profile::span("fuzzy_completion"); let potential_import_name = ctx.token.to_string(); + if potential_import_name.len() < 2 { + return None; + } + 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)?; @@ -133,7 +138,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() let mut all_mod_paths = imports_locator::find_similar_imports( &ctx.sema, ctx.krate?, - Some(100), + Some(40), &potential_import_name, true, ) -- cgit v1.2.3