aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src')
-rw-r--r--crates/completion/src/completions/unqualified_path.rs54
-rw-r--r--crates/completion/src/render.rs1
2 files changed, 29 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(())
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index e892d4de8..bce02f577 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -150,6 +150,7 @@ impl<'a> Render<'a> {
150 import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, 150 import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>,
151 resolution: &ScopeDef, 151 resolution: &ScopeDef,
152 ) -> Option<CompletionItem> { 152 ) -> Option<CompletionItem> {
153 let _p = profile::span("render_resolution");
153 use hir::ModuleDef::*; 154 use hir::ModuleDef::*;
154 155
155 let completion_kind = match resolution { 156 let completion_kind = match resolution {