From 69e9d75678d8ac9e58fba07a4b7f0f486fea4770 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Wed, 22 May 2024 13:47:05 -0700 Subject: [PATCH] Allow searching with prefix --- src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs b/src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs index e14cf0eb1f7f..5e1930e6021d 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs @@ -381,7 +381,7 @@ impl Query { if non_type_for_type_only_query || !self.matches_assoc_mode(symbol.is_assoc) { continue; } - if !self.include_hidden && symbol.name.starts_with("__") { + if self.should_hide_query(&symbol) { continue; } if self.mode.check(&self.query, self.case_sensitive, &symbol.name) { @@ -392,6 +392,11 @@ impl Query { } } + fn should_hide_query(&self, symbol: &FileSymbol) -> bool { + // Hide symbols that start with `__` unless the query starts with `__` + !self.include_hidden && symbol.name.starts_with("__") && !self.query.starts_with("__") + } + fn matches_assoc_mode(&self, is_trait_assoc_item: bool) -> bool { !matches!( (is_trait_assoc_item, self.assoc_mode),