diff options
Diffstat (limited to 'crates/completion/src/completions')
-rw-r--r-- | crates/completion/src/completions/unqualified_path.rs | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 4f1c9faa0..3bd776905 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs | |||
@@ -81,32 +81,34 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() | |||
81 | 81 | ||
82 | let potential_import_name = ctx.token.to_string(); | 82 | let potential_import_name = ctx.token.to_string(); |
83 | 83 | ||
84 | let possible_imports = | 84 | let possible_imports = imports_locator::find_similar_imports( |
85 | imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400) | 85 | &ctx.sema, |
86 | .filter_map(|import_candidate| match import_candidate { | 86 | ctx.krate?, |
87 | // when completing outside the use declaration, modules are pretty useless | 87 | &potential_import_name, |
88 | // and tend to bloat the completion suggestions a lot | 88 | 50, |
89 | Either::Left(ModuleDef::Module(_)) => None, | 89 | true, |
90 | Either::Left(module_def) => Some(( | 90 | ) |
91 | current_module.find_use_path(ctx.db, module_def)?, | 91 | .filter_map(|import_candidate| { |
92 | ScopeDef::ModuleDef(module_def), | 92 | Some(match import_candidate { |
93 | )), | 93 | Either::Left(module_def) => { |
94 | Either::Right(macro_def) => Some(( | 94 | (current_module.find_use_path(ctx.db, module_def)?, ScopeDef::ModuleDef(module_def)) |
95 | current_module.find_use_path(ctx.db, macro_def)?, | 95 | } |
96 | ScopeDef::MacroDef(macro_def), | 96 | Either::Right(macro_def) => { |
97 | )), | 97 | (current_module.find_use_path(ctx.db, macro_def)?, ScopeDef::MacroDef(macro_def)) |
98 | }) | 98 | } |
99 | .filter(|(mod_path, _)| mod_path.len() > 1) | 99 | }) |
100 | .filter_map(|(import_path, definition)| { | 100 | }) |
101 | render_resolution_with_import( | 101 | .filter(|(mod_path, _)| mod_path.len() > 1) |
102 | RenderContext::new(ctx), | 102 | .take(20) |
103 | import_path.clone(), | 103 | .filter_map(|(import_path, definition)| { |
104 | import_scope.clone(), | 104 | render_resolution_with_import( |
105 | ctx.config.merge, | 105 | RenderContext::new(ctx), |
106 | &definition, | 106 | import_path.clone(), |
107 | ) | 107 | import_scope.clone(), |
108 | }) | 108 | ctx.config.merge, |
109 | .take(20); | 109 | &definition, |
110 | ) | ||
111 | }); | ||
110 | 112 | ||
111 | acc.add_all(possible_imports); | 113 | acc.add_all(possible_imports); |
112 | Some(()) | 114 | Some(()) |