aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src')
-rw-r--r--crates/completion/src/completions/magic.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/completion/src/completions/magic.rs b/crates/completion/src/completions/magic.rs
index 2ac6f94a9..0c4db0199 100644
--- a/crates/completion/src/completions/magic.rs
+++ b/crates/completion/src/completions/magic.rs
@@ -2,7 +2,7 @@
2 2
3use assists::utils::{insert_use, mod_path_to_ast, ImportScope}; 3use assists::utils::{insert_use, mod_path_to_ast, ImportScope};
4use either::Either; 4use either::Either;
5use hir::ScopeDef; 5use hir::{ModuleDef, ScopeDef};
6use ide_db::imports_locator; 6use ide_db::imports_locator;
7use syntax::{algo, AstNode}; 7use syntax::{algo, AstNode};
8 8
@@ -13,7 +13,6 @@ use crate::{
13 13
14use super::Completions; 14use super::Completions;
15 15
16// TODO kb reuse auto_import assist approach to add trait completion
17// TODO kb add a setting toggle for this feature? 16// TODO kb add a setting toggle for this feature?
18pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 17pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
19 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { 18 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
@@ -28,17 +27,18 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) ->
28 27
29 let possible_imports = 28 let possible_imports =
30 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400) 29 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400)
31 .filter_map(|import_candidate| { 30 .filter_map(|import_candidate| match import_candidate {
32 Some(match import_candidate { 31 // when completing outside the use declaration, modules are pretty useless
33 Either::Left(module_def) => ( 32 // and tend to bloat the completion suggestions a lot
34 current_module.find_use_path(ctx.db, module_def)?, 33 Either::Left(ModuleDef::Module(_)) => None,
35 ScopeDef::ModuleDef(module_def), 34 Either::Left(module_def) => Some((
36 ), 35 current_module.find_use_path(ctx.db, module_def)?,
37 Either::Right(macro_def) => ( 36 ScopeDef::ModuleDef(module_def),
38 current_module.find_use_path(ctx.db, macro_def)?, 37 )),
39 ScopeDef::MacroDef(macro_def), 38 Either::Right(macro_def) => Some((
40 ), 39 current_module.find_use_path(ctx.db, macro_def)?,
41 }) 40 ScopeDef::MacroDef(macro_def),
41 )),
42 }) 42 })
43 .filter_map(|(mod_path, definition)| { 43 .filter_map(|(mod_path, definition)| {
44 let mut resolution_with_missing_import = render_resolution( 44 let mut resolution_with_missing_import = render_resolution(