aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-29 12:19:31 +0000
committerGitHub <[email protected]>2020-12-29 12:19:31 +0000
commitef1177c5b5a7ced9866025a51c10e4375e2a37fd (patch)
tree347f2a22132be0106d4703526288665b6d33a136 /crates/completion/src
parent7b246a6a14a8170f99dd5992f7d9dd4347722a69 (diff)
parent77b4a1c5ef594ddd78c77dd8bb05fba14b99cc9f (diff)
Merge #7064
7064: Ignore qualifiers when doing autoimport completions lookup r=lnicola a=SomeoneToIgnore A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6918#issuecomment-748511151 and the PR itself. Tweaks the `import_map` query api to be more flexible with the ways to match against the import path and now fuzzy imports search in names only. This had improved the completion speed for me locally in ~5 times for `fuzzy_completion` span time, but please recheck me here. IMO we're fast and presice enough now, so I've added the modules back to the fuzzy search output. Also tweaks the the expect tests to display functions explicitly, to avoid confusing "duplicate" results. Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/completion/src')
-rw-r--r--crates/completion/src/completions/unqualified_path.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index d09849752..59f950189 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -101,8 +101,9 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
101// 101//
102// .Fuzzy search details 102// .Fuzzy search details
103// 103//
104// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only 104// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the names only
105// (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers. 105// (i.e. in `HashMap` in the `std::collections::HashMap` path).
106// For the same reasons, avoids searching for any imports for inputs with their length less that 2 symbols.
106// 107//
107// .Merge Behavior 108// .Merge Behavior
108// 109//
@@ -126,6 +127,10 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
126 let _p = profile::span("fuzzy_completion"); 127 let _p = profile::span("fuzzy_completion");
127 let potential_import_name = ctx.token.to_string(); 128 let potential_import_name = ctx.token.to_string();
128 129
130 if potential_import_name.len() < 2 {
131 return None;
132 }
133
129 let current_module = ctx.scope.module()?; 134 let current_module = ctx.scope.module()?;
130 let anchor = ctx.name_ref_syntax.as_ref()?; 135 let anchor = ctx.name_ref_syntax.as_ref()?;
131 let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; 136 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<()
133 let mut all_mod_paths = imports_locator::find_similar_imports( 138 let mut all_mod_paths = imports_locator::find_similar_imports(
134 &ctx.sema, 139 &ctx.sema,
135 ctx.krate?, 140 ctx.krate?,
136 Some(100), 141 Some(40),
137 &potential_import_name, 142 &potential_import_name,
138 true, 143 true,
139 ) 144 )