From 0415dcd8324f1acf726315fdaba919c11ab7a462 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 19 Dec 2020 13:27:10 +0200 Subject: Tidy up --- crates/completion/src/completions/trait_impl.rs | 10 ++--- .../completion/src/completions/unqualified_path.rs | 48 ++++++++++------------ 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 { t<|> } "#, - expect![[r#" - ta type TestType = - ct const TEST_CONST: u16 = - fn fn test() - "#]], + expect![[" +ta type TestType = \n\ +ct const TEST_CONST: u16 = \n\ +fn fn test() +"]], ); } 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<() acc.add_all(all_mod_paths.into_iter().filter_map(|(import_path, definition)| { render_resolution_with_import( RenderContext::new(ctx), - ImportEdit { import_path: import_path, import_scope: import_scope.clone() }, + ImportEdit { import_path, import_scope: import_scope.clone() }, &definition, ) })); Some(()) } -// todo kb add tet marks for the completion order test + the sotring description fn compute_fuzzy_completion_order_key(proposed_mod_path: &ModPath, user_input: &str) -> usize { + mark::hit!(certain_fuzzy_order_test); let proposed_import_name = match proposed_mod_path.segments.last() { Some(name) => name.to_string().to_lowercase(), None => return usize::MAX, @@ -193,6 +193,14 @@ mod tests { expect.assert_eq(&actual) } + fn fuzzy_completion_config() -> CompletionConfig { + let mut completion_config = CompletionConfig::default(); + completion_config + .active_resolve_capabilities + .insert(crate::CompletionResolveCapability::AdditionalTextEdits); + completion_config + } + #[test] fn self_fulfilling_completion() { mark::check!(self_fulfilling_completion); @@ -794,13 +802,8 @@ impl My<|> #[test] fn function_fuzzy_completion() { - let mut completion_config = CompletionConfig::default(); - completion_config - .active_resolve_capabilities - .insert(crate::CompletionResolveCapability::AdditionalTextEdits); - check_edit_with_config( - completion_config, + fuzzy_completion_config(), "stdin", r#" //- /lib.rs crate:dep @@ -825,13 +828,8 @@ fn main() { #[test] fn macro_fuzzy_completion() { - let mut completion_config = CompletionConfig::default(); - completion_config - .active_resolve_capabilities - .insert(crate::CompletionResolveCapability::AdditionalTextEdits); - check_edit_with_config( - completion_config, + fuzzy_completion_config(), "macro_with_curlies!", r#" //- /lib.rs crate:dep @@ -858,13 +856,8 @@ fn main() { #[test] fn struct_fuzzy_completion() { - let mut completion_config = CompletionConfig::default(); - completion_config - .active_resolve_capabilities - .insert(crate::CompletionResolveCapability::AdditionalTextEdits); - check_edit_with_config( - completion_config, + fuzzy_completion_config(), "ThirdStruct", r#" //- /lib.rs crate:dep @@ -893,21 +886,22 @@ fn main() { #[test] fn fuzzy_completions_come_in_specific_order() { - let mut completion_config = CompletionConfig::default(); - completion_config - .active_resolve_capabilities - .insert(crate::CompletionResolveCapability::AdditionalTextEdits); - + mark::check!(certain_fuzzy_order_test); check_with_config( - completion_config, + fuzzy_completion_config(), r#" //- /lib.rs crate:dep pub struct FirstStruct; pub mod some_module { + // already imported, omitted pub struct SecondStruct; - + // does not contain all letters from the query, omitted + pub struct UnrelatedOne; + // contains all letters from the query, but not in sequence, displayed last pub struct ThiiiiiirdStruct; + // contains all letters from the query, but not in the beginning, displayed second pub struct AfterThirdStruct; + // contains all letters from the query in the begginning, displayed first pub struct ThirdStruct; } -- cgit v1.2.3