aboutsummaryrefslogtreecommitdiff
path: root/crates/completion
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-12-19 11:27:10 +0000
committerKirill Bulatov <[email protected]>2020-12-19 12:13:27 +0000
commit0415dcd8324f1acf726315fdaba919c11ab7a462 (patch)
treea1ebe58800e53dc4200c60504059572b380f4803 /crates/completion
parent8c292e3cc5bd79f4204e25d0ca7e712e9496d6da (diff)
Tidy up
Diffstat (limited to 'crates/completion')
-rw-r--r--crates/completion/src/completions/trait_impl.rs10
-rw-r--r--crates/completion/src/completions/unqualified_path.rs48
2 files changed, 26 insertions, 32 deletions
diff --git a/crates/completion/src/completions/trait_impl.rs b/crates/completion/src/completions/trait_impl.rs
index ca2b1bc3b..c4e0d0669 100644
--- a/crates/completion/src/completions/trait_impl.rs
+++ b/crates/completion/src/completions/trait_impl.rs
@@ -265,11 +265,11 @@ impl Test for T {
265 t<|> 265 t<|>
266} 266}
267"#, 267"#,
268 expect![[r#" 268 expect![["
269 ta type TestType = 269ta type TestType = \n\
270 ct const TEST_CONST: u16 = 270ct const TEST_CONST: u16 = \n\
271 fn fn test() 271fn fn test()
272 "#]], 272"]],
273 ); 273 );
274 } 274 }
275 275
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 54d5c989b..0fbcf4f8c 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -153,15 +153,15 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
153 acc.add_all(all_mod_paths.into_iter().filter_map(|(import_path, definition)| { 153 acc.add_all(all_mod_paths.into_iter().filter_map(|(import_path, definition)| {
154 render_resolution_with_import( 154 render_resolution_with_import(
155 RenderContext::new(ctx), 155 RenderContext::new(ctx),
156 ImportEdit { import_path: import_path, import_scope: import_scope.clone() }, 156 ImportEdit { import_path, import_scope: import_scope.clone() },
157 &definition, 157 &definition,
158 ) 158 )
159 })); 159 }));
160 Some(()) 160 Some(())
161} 161}
162 162
163// todo kb add tet marks for the completion order test + the sotring description
164fn compute_fuzzy_completion_order_key(proposed_mod_path: &ModPath, user_input: &str) -> usize { 163fn compute_fuzzy_completion_order_key(proposed_mod_path: &ModPath, user_input: &str) -> usize {
164 mark::hit!(certain_fuzzy_order_test);
165 let proposed_import_name = match proposed_mod_path.segments.last() { 165 let proposed_import_name = match proposed_mod_path.segments.last() {
166 Some(name) => name.to_string().to_lowercase(), 166 Some(name) => name.to_string().to_lowercase(),
167 None => return usize::MAX, 167 None => return usize::MAX,
@@ -193,6 +193,14 @@ mod tests {
193 expect.assert_eq(&actual) 193 expect.assert_eq(&actual)
194 } 194 }
195 195
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
196 #[test] 204 #[test]
197 fn self_fulfilling_completion() { 205 fn self_fulfilling_completion() {
198 mark::check!(self_fulfilling_completion); 206 mark::check!(self_fulfilling_completion);
@@ -794,13 +802,8 @@ impl My<|>
794 802
795 #[test] 803 #[test]
796 fn function_fuzzy_completion() { 804 fn function_fuzzy_completion() {
797 let mut completion_config = CompletionConfig::default();
798 completion_config
799 .active_resolve_capabilities
800 .insert(crate::CompletionResolveCapability::AdditionalTextEdits);
801
802 check_edit_with_config( 805 check_edit_with_config(
803 completion_config, 806 fuzzy_completion_config(),
804 "stdin", 807 "stdin",
805 r#" 808 r#"
806//- /lib.rs crate:dep 809//- /lib.rs crate:dep
@@ -825,13 +828,8 @@ fn main() {
825 828
826 #[test] 829 #[test]
827 fn macro_fuzzy_completion() { 830 fn macro_fuzzy_completion() {
828 let mut completion_config = CompletionConfig::default();
829 completion_config
830 .active_resolve_capabilities
831 .insert(crate::CompletionResolveCapability::AdditionalTextEdits);
832
833 check_edit_with_config( 831 check_edit_with_config(
834 completion_config, 832 fuzzy_completion_config(),
835 "macro_with_curlies!", 833 "macro_with_curlies!",
836 r#" 834 r#"
837//- /lib.rs crate:dep 835//- /lib.rs crate:dep
@@ -858,13 +856,8 @@ fn main() {
858 856
859 #[test] 857 #[test]
860 fn struct_fuzzy_completion() { 858 fn struct_fuzzy_completion() {
861 let mut completion_config = CompletionConfig::default();
862 completion_config
863 .active_resolve_capabilities
864 .insert(crate::CompletionResolveCapability::AdditionalTextEdits);
865
866 check_edit_with_config( 859 check_edit_with_config(
867 completion_config, 860 fuzzy_completion_config(),
868 "ThirdStruct", 861 "ThirdStruct",
869 r#" 862 r#"
870//- /lib.rs crate:dep 863//- /lib.rs crate:dep
@@ -893,21 +886,22 @@ fn main() {
893 886
894 #[test] 887 #[test]
895 fn fuzzy_completions_come_in_specific_order() { 888 fn fuzzy_completions_come_in_specific_order() {
896 let mut completion_config = CompletionConfig::default(); 889 mark::check!(certain_fuzzy_order_test);
897 completion_config
898 .active_resolve_capabilities
899 .insert(crate::CompletionResolveCapability::AdditionalTextEdits);
900
901 check_with_config( 890 check_with_config(
902 completion_config, 891 fuzzy_completion_config(),
903 r#" 892 r#"
904//- /lib.rs crate:dep 893//- /lib.rs crate:dep
905pub struct FirstStruct; 894pub struct FirstStruct;
906pub mod some_module { 895pub mod some_module {
896 // already imported, omitted
907 pub struct SecondStruct; 897 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
909 pub struct ThiiiiiirdStruct; 901 pub struct ThiiiiiirdStruct;
902 // contains all letters from the query, but not in the beginning, displayed second
910 pub struct AfterThirdStruct; 903 pub struct AfterThirdStruct;
904 // contains all letters from the query in the begginning, displayed first
911 pub struct ThirdStruct; 905 pub struct ThirdStruct;
912} 906}
913 907