@@ -99,7 +99,6 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
9999//
100100// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only
101101// (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers.
102- // It also avoids searching for any imports for inputs with their length less that 3 symbols.
103102//
104103// .Merge Behaviour
105104//
@@ -123,40 +122,39 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
123122 let _p = profile:: span ( "fuzzy_completion" ) ;
124123 let potential_import_name = ctx. token . to_string ( ) ;
125124
126- if potential_import_name. len ( ) < 3 {
127- return None ;
128- }
129-
130125 let current_module = ctx. scope . module ( ) ?;
131126 let anchor = ctx. name_ref_syntax . as_ref ( ) ?;
132127 let import_scope = ImportScope :: find_insert_use_container ( anchor. syntax ( ) , & ctx. sema ) ?;
133128
134- let possible_imports =
135- imports_locator:: find_similar_imports ( & ctx. sema , ctx. krate ?, & potential_import_name, true )
136- . filter_map ( |import_candidate| {
137- Some ( match import_candidate {
138- Either :: Left ( module_def) => (
139- current_module. find_use_path ( ctx. db , module_def) ?,
140- ScopeDef :: ModuleDef ( module_def) ,
141- ) ,
142- Either :: Right ( macro_def) => (
143- current_module. find_use_path ( ctx. db , macro_def) ?,
144- ScopeDef :: MacroDef ( macro_def) ,
145- ) ,
146- } )
147- } )
148- . filter ( |( mod_path, _) | mod_path. len ( ) > 1 )
149- . filter_map ( |( import_path, definition) | {
150- render_resolution_with_import (
151- RenderContext :: new ( ctx) ,
152- ImportEdit {
153- import_path : import_path. clone ( ) ,
154- import_scope : import_scope. clone ( ) ,
155- merge_behaviour : ctx. config . merge ,
156- } ,
157- & definition,
158- )
159- } ) ;
129+ let possible_imports = imports_locator:: find_similar_imports (
130+ & ctx. sema ,
131+ ctx. krate ?,
132+ Some ( 100 ) ,
133+ & potential_import_name,
134+ true ,
135+ )
136+ . filter_map ( |import_candidate| {
137+ Some ( match import_candidate {
138+ Either :: Left ( module_def) => {
139+ ( current_module. find_use_path ( ctx. db , module_def) ?, ScopeDef :: ModuleDef ( module_def) )
140+ }
141+ Either :: Right ( macro_def) => {
142+ ( current_module. find_use_path ( ctx. db , macro_def) ?, ScopeDef :: MacroDef ( macro_def) )
143+ }
144+ } )
145+ } )
146+ . filter ( |( mod_path, _) | mod_path. len ( ) > 1 )
147+ . filter_map ( |( import_path, definition) | {
148+ render_resolution_with_import (
149+ RenderContext :: new ( ctx) ,
150+ ImportEdit {
151+ import_path : import_path. clone ( ) ,
152+ import_scope : import_scope. clone ( ) ,
153+ merge_behaviour : ctx. config . merge ,
154+ } ,
155+ & definition,
156+ )
157+ } ) ;
160158
161159 acc. add_all ( possible_imports) ;
162160 Some ( ( ) )
0 commit comments