about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan Kelley <jkelleyrtp@gmail.com>2024-05-22 13:47:05 -0700
committerJonathan Kelley <jkelleyrtp@gmail.com>2024-05-22 13:47:05 -0700
commit69e9d75678d8ac9e58fba07a4b7f0f486fea4770 (patch)
treea71b42e05de20a577a65f9e88986d9da70514133
parentada256c09e0f1f75bbba92771cfc4e35057a2ad8 (diff)
downloadrust-69e9d75678d8ac9e58fba07a4b7f0f486fea4770.tar.gz
rust-69e9d75678d8ac9e58fba07a4b7f0f486fea4770.zip
Allow searching with prefix
-rw-r--r--src/tools/rust-analyzer/crates/ide-db/src/symbol_index.rs7
1 files changed, 6 insertions, 1 deletions
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 e14cf0eb1f7..5e1930e6021 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),