@@ -153,15 +153,15 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
153153 acc. add_all ( all_mod_paths. into_iter ( ) . filter_map ( |( import_path, definition) | {
154154 render_resolution_with_import (
155155 RenderContext :: new ( ctx) ,
156- ImportEdit { import_path : import_path , import_scope : import_scope. clone ( ) } ,
156+ ImportEdit { import_path, import_scope : import_scope. clone ( ) } ,
157157 & definition,
158158 )
159159 } ) ) ;
160160 Some ( ( ) )
161161}
162162
163- // todo kb add tet marks for the completion order test + the sotring description
164163fn compute_fuzzy_completion_order_key ( proposed_mod_path : & ModPath , user_input : & str ) -> usize {
164+ mark:: hit!( certain_fuzzy_order_test) ;
165165 let proposed_import_name = match proposed_mod_path. segments . last ( ) {
166166 Some ( name) => name. to_string ( ) . to_lowercase ( ) ,
167167 None => return usize:: MAX ,
@@ -193,6 +193,14 @@ mod tests {
193193 expect. assert_eq ( & actual)
194194 }
195195
196+ fn fuzzy_completion_config ( ) -> CompletionConfig {
197+ let mut completion_config = CompletionConfig :: default ( ) ;
198+ completion_config
199+ . active_resolve_capabilities
200+ . insert ( crate :: CompletionResolveCapability :: AdditionalTextEdits ) ;
201+ completion_config
202+ }
203+
196204 #[ test]
197205 fn self_fulfilling_completion ( ) {
198206 mark:: check!( self_fulfilling_completion) ;
@@ -794,13 +802,8 @@ impl My<|>
794802
795803 #[ test]
796804 fn function_fuzzy_completion ( ) {
797- let mut completion_config = CompletionConfig :: default ( ) ;
798- completion_config
799- . active_resolve_capabilities
800- . insert ( crate :: CompletionResolveCapability :: AdditionalTextEdits ) ;
801-
802805 check_edit_with_config (
803- completion_config ,
806+ fuzzy_completion_config ( ) ,
804807 "stdin" ,
805808 r#"
806809//- /lib.rs crate:dep
@@ -825,13 +828,8 @@ fn main() {
825828
826829 #[ test]
827830 fn macro_fuzzy_completion ( ) {
828- let mut completion_config = CompletionConfig :: default ( ) ;
829- completion_config
830- . active_resolve_capabilities
831- . insert ( crate :: CompletionResolveCapability :: AdditionalTextEdits ) ;
832-
833831 check_edit_with_config (
834- completion_config ,
832+ fuzzy_completion_config ( ) ,
835833 "macro_with_curlies!" ,
836834 r#"
837835//- /lib.rs crate:dep
@@ -858,13 +856,8 @@ fn main() {
858856
859857 #[ test]
860858 fn struct_fuzzy_completion ( ) {
861- let mut completion_config = CompletionConfig :: default ( ) ;
862- completion_config
863- . active_resolve_capabilities
864- . insert ( crate :: CompletionResolveCapability :: AdditionalTextEdits ) ;
865-
866859 check_edit_with_config (
867- completion_config ,
860+ fuzzy_completion_config ( ) ,
868861 "ThirdStruct" ,
869862 r#"
870863//- /lib.rs crate:dep
@@ -893,21 +886,22 @@ fn main() {
893886
894887 #[ test]
895888 fn fuzzy_completions_come_in_specific_order ( ) {
896- let mut completion_config = CompletionConfig :: default ( ) ;
897- completion_config
898- . active_resolve_capabilities
899- . insert ( crate :: CompletionResolveCapability :: AdditionalTextEdits ) ;
900-
889+ mark:: check!( certain_fuzzy_order_test) ;
901890 check_with_config (
902- completion_config ,
891+ fuzzy_completion_config ( ) ,
903892 r#"
904893//- /lib.rs crate:dep
905894pub struct FirstStruct;
906895pub mod some_module {
896+ // already imported, omitted
907897 pub struct SecondStruct;
908-
898+ // does not contain all letters from the query, omitted
899+ pub struct UnrelatedOne;
900+ // contains all letters from the query, but not in sequence, displayed last
909901 pub struct ThiiiiiirdStruct;
902+ // contains all letters from the query, but not in the beginning, displayed second
910903 pub struct AfterThirdStruct;
904+ // contains all letters from the query in the begginning, displayed first
911905 pub struct ThirdStruct;
912906}
913907
0 commit comments