From ec731e19df6444b2113c273fc740fd3d5c866b18 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 20 Mar 2021 23:55:16 +0200 Subject: Use smart case in flyimport items lookup --- crates/ide_completion/src/completions/flyimport.rs | 61 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index eb2cba631..1ad017198 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -1,8 +1,10 @@ //! Feature: completion with imports-on-the-fly //! //! When completing names in the current scope, proposes additional imports from other modules or crates, -//! if they can be qualified in the scope and their name contains all symbols from the completion input -//! (case-insensitive, in any order or places). +//! if they can be qualified in the scope and their name contains all symbols from the completion input. +//! +//! To be considered applicable, the name must contain all input symbols in the given order, not necessarily adjacent. +//! If any input symbol is not lowercased, the name must contain all symbols in exact case; otherwise the contaning is checked case-insensitively. //! //! ``` //! fn main() { @@ -942,7 +944,7 @@ mod foo { } fn main() { - bar::Ass$0 + bar::ASS$0 }"#, expect![[]], ) @@ -979,4 +981,57 @@ fn main() { expect![[]], ) } + + #[test] + fn case_matters() { + check( + r#" +mod foo { + pub const TEST_CONST: usize = 3; + pub fn test_function() -> i32 { + 4 + } +} + +fn main() { + TE$0 +}"#, + expect![[r#" + ct foo::TEST_CONST + "#]], + ); + + check( + r#" +mod foo { + pub const TEST_CONST: usize = 3; + pub fn test_function() -> i32 { + 4 + } +} + +fn main() { + te$0 +}"#, + expect![[r#" + ct foo::TEST_CONST + fn test_function() (foo::test_function) fn() -> i32 + "#]], + ); + + check( + r#" +mod foo { + pub const TEST_CONST: usize = 3; + pub fn test_function() -> i32 { + 4 + } +} + +fn main() { + Te$0 +}"#, + expect![[]], + ); + } } -- cgit v1.2.3 From eaa4fcbbdea69c8fcf5b6cdc1ff3c259be3e09cb Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 21 Mar 2021 00:17:09 +0200 Subject: Less reallocations --- crates/ide_completion/src/lib.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs index 87cddb98e..5ac1cb48d 100644 --- a/crates/ide_completion/src/lib.rs +++ b/crates/ide_completion/src/lib.rs @@ -161,7 +161,6 @@ pub fn resolve_completion_edits( items_locator::AssocItemSearch::Include, Some(items_locator::DEFAULT_QUERY_SEARCH_LIMIT), ) - .into_iter() .filter_map(|candidate| { current_module .find_use_path_prefixed(db, candidate, config.insert_use.prefix_kind) -- cgit v1.2.3