Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/navigation_target.rs')
-rw-r--r--crates/ide/src/navigation_target.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs
index fc836d5540..a93a8da57e 100644
--- a/crates/ide/src/navigation_target.rs
+++ b/crates/ide/src/navigation_target.rs
@@ -926,4 +926,26 @@ struct Foo;
let navs = analysis.symbol_search(Query::new("foo".to_owned()), !0).unwrap();
assert_eq!(navs.len(), 2)
}
+
+ #[test]
+ fn test_ensure_hidden_symbols_are_not_returned() {
+ let (analysis, _) = fixture::file(
+ r#"
+fn foo() {}
+struct Foo;
+static __FOO_CALLSITE: () = ();
+"#,
+ );
+
+ // It doesn't show the hidden symbol
+ let navs = analysis.symbol_search(Query::new("foo".to_owned()), !0).unwrap();
+ assert_eq!(navs.len(), 2);
+ let navs = analysis.symbol_search(Query::new("_foo".to_owned()), !0).unwrap();
+ assert_eq!(navs.len(), 0);
+
+ // Unless we explicitly search for a `__` prefix
+ let query = Query::new("__foo".to_owned());
+ let navs = analysis.symbol_search(query, !0).unwrap();
+ assert_eq!(navs.len(), 1);
+ }
}