diff options
author | Kirill Bulatov <[email protected]> | 2020-11-24 00:26:16 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-11-24 00:28:45 +0000 |
commit | 4baac238a8343d7c5ced58603bf122c66cbf8c82 (patch) | |
tree | eb898d8429aafb3b19e356089bed57994fbbe015 /crates/ide_db | |
parent | 036ea6317c7e0a48acafcdcf8ece3a4816fa4036 (diff) |
Improve autoimports on completion speed
* Ignore modules eaferly
* Do less completion string rendering
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index 9d8ea7368..09046d3c3 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -36,8 +36,15 @@ pub fn find_similar_imports<'a>( | |||
36 | krate: Crate, | 36 | krate: Crate, |
37 | name_to_import: &str, | 37 | name_to_import: &str, |
38 | limit: usize, | 38 | limit: usize, |
39 | ignore_modules: bool, | ||
39 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 40 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
40 | let _p = profile::span("find_similar_imports"); | 41 | let _p = profile::span("find_similar_imports"); |
42 | |||
43 | let mut external_query = import_map::Query::new(name_to_import).limit(limit); | ||
44 | if ignore_modules { | ||
45 | external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); | ||
46 | } | ||
47 | |||
41 | find_imports( | 48 | find_imports( |
42 | sema, | 49 | sema, |
43 | krate, | 50 | krate, |
@@ -46,7 +53,7 @@ pub fn find_similar_imports<'a>( | |||
46 | local_query.limit(limit); | 53 | local_query.limit(limit); |
47 | local_query | 54 | local_query |
48 | }, | 55 | }, |
49 | import_map::Query::new(name_to_import).limit(limit), | 56 | external_query, |
50 | ) | 57 | ) |
51 | } | 58 | } |
52 | 59 | ||