diff options
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/items_locator.rs | 9 | ||||
-rw-r--r-- | crates/ide_db/src/symbol_index.rs | 16 |
2 files changed, 22 insertions, 3 deletions
diff --git a/crates/ide_db/src/items_locator.rs b/crates/ide_db/src/items_locator.rs index 518cddd74..b9d5852e2 100644 --- a/crates/ide_db/src/items_locator.rs +++ b/crates/ide_db/src/items_locator.rs | |||
@@ -62,6 +62,8 @@ pub fn items_with_name( | |||
62 | (local_query, external_query) | 62 | (local_query, external_query) |
63 | } | 63 | } |
64 | NameToImport::Fuzzy(fuzzy_search_string) => { | 64 | NameToImport::Fuzzy(fuzzy_search_string) => { |
65 | let mut local_query = symbol_index::Query::new(fuzzy_search_string.clone()); | ||
66 | |||
65 | let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) | 67 | let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) |
66 | .search_mode(import_map::SearchMode::Fuzzy) | 68 | .search_mode(import_map::SearchMode::Fuzzy) |
67 | .name_only(); | 69 | .name_only(); |
@@ -75,7 +77,12 @@ pub fn items_with_name( | |||
75 | } | 77 | } |
76 | } | 78 | } |
77 | 79 | ||
78 | (symbol_index::Query::new(fuzzy_search_string), external_query) | 80 | if fuzzy_search_string.to_lowercase() != fuzzy_search_string { |
81 | local_query.case_sensitive(); | ||
82 | external_query = external_query.case_sensitive(); | ||
83 | } | ||
84 | |||
85 | (local_query, external_query) | ||
79 | } | 86 | } |
80 | }; | 87 | }; |
81 | 88 | ||
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs index 9ed9568ce..35e382b5c 100644 --- a/crates/ide_db/src/symbol_index.rs +++ b/crates/ide_db/src/symbol_index.rs | |||
@@ -52,6 +52,7 @@ pub struct Query { | |||
52 | only_types: bool, | 52 | only_types: bool, |
53 | libs: bool, | 53 | libs: bool, |
54 | exact: bool, | 54 | exact: bool, |
55 | case_sensitive: bool, | ||
55 | limit: usize, | 56 | limit: usize, |
56 | } | 57 | } |
57 | 58 | ||
@@ -64,6 +65,7 @@ impl Query { | |||
64 | only_types: false, | 65 | only_types: false, |
65 | libs: false, | 66 | libs: false, |
66 | exact: false, | 67 | exact: false, |
68 | case_sensitive: false, | ||
67 | limit: usize::max_value(), | 69 | limit: usize::max_value(), |
68 | } | 70 | } |
69 | } | 71 | } |
@@ -80,6 +82,10 @@ impl Query { | |||
80 | self.exact = true; | 82 | self.exact = true; |
81 | } | 83 | } |
82 | 84 | ||
85 | pub fn case_sensitive(&mut self) { | ||
86 | self.case_sensitive = true; | ||
87 | } | ||
88 | |||
83 | pub fn limit(&mut self, limit: usize) { | 89 | pub fn limit(&mut self, limit: usize) { |
84 | self.limit = limit | 90 | self.limit = limit |
85 | } | 91 | } |
@@ -326,8 +332,14 @@ impl Query { | |||
326 | if self.only_types && !symbol.kind.is_type() { | 332 | if self.only_types && !symbol.kind.is_type() { |
327 | continue; | 333 | continue; |
328 | } | 334 | } |
329 | if self.exact && symbol.name != self.query { | 335 | if self.exact { |
330 | continue; | 336 | if symbol.name != self.query { |
337 | continue; | ||
338 | } | ||
339 | } else if self.case_sensitive { | ||
340 | if self.query.chars().any(|c| !symbol.name.contains(c)) { | ||
341 | continue; | ||
342 | } | ||
331 | } | 343 | } |
332 | 344 | ||
333 | res.push(symbol.clone()); | 345 | res.push(symbol.clone()); |