diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 66fd7295a058f1f2ec2ee74d6be78133e7c88219..997f2bf5ef801a1191f25cb06fd4de0d558fd2ad 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -13,7 +13,18 @@ path = "src/agent_ui.rs" doctest = false [features] -test-support = ["assistant_text_thread/test-support", "acp_thread/test-support", "eval_utils", "gpui/test-support", "language/test-support", "reqwest_client", "workspace/test-support", "agent/test-support", "rules_library/test-support"] +test-support = [ + "assistant_text_thread/test-support", + "acp_thread/test-support", + "eval_utils", + "gpui/test-support", + "git_ui/test-support", + "language/test-support", + "reqwest_client", + "workspace/test-support", + "agent/test-support", + "rules_library/test-support" +] unit-eval = [] [dependencies] @@ -116,6 +127,8 @@ db = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } eval_utils.workspace = true gpui = { workspace = true, "features" = ["test-support"] } +git_ui = { workspace = true, features = ["test-support"] } +rules_library = { workspace = true, features = ["test-support"] } indoc.workspace = true language = { workspace = true, "features" = ["test-support"] } languages = { workspace = true, features = ["test-support"] } diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index e866f453936f7727c3ec00b3c30bd9d674cf5f4c..6eb3a559e8e264a2d683bf8f0a0230a318c93f1a 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -1556,7 +1556,15 @@ pub(crate) fn search_symbols( SymbolLocation::OutsideProject { .. } => false, }) }); - + // Try to support rust-analyzer's path based symbols feature which + // allows to search by rust path syntax, in that case we only want to + // filter names by the last segment + // Ideally this was a first class LSP feature (rich queries) + let query = query + .rsplit_once("::") + .map_or(&*query, |(_, suffix)| suffix) + .to_owned(); + // Note if you make changes to this filtering below, also change `project_symbols::ProjectSymbolsDelegate::filter` const MAX_MATCHES: usize = 100; let mut visible_matches = cx.background_executor().block(fuzzy::match_strings( &visible_match_candidates, @@ -2012,6 +2020,19 @@ mod tests { }) ); + assert_eq!( + MentionCompletion::try_parse( + "Lorem @symbol agent_ui::completion_provider", + 0, + &supported_modes + ), + Some(MentionCompletion { + source_range: 6..43, + mode: Some(PromptContextType::Symbol), + argument: Some("agent_ui::completion_provider".to_string()), + }) + ); + // Disallowed non-file mentions assert_eq!( MentionCompletion::try_parse("Lorem @symbol main", 0, &[PromptContextType::File]), diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 4c077cb69f57c884ea9cfae6e17fc5b0921001dc..3a8c60ef43ff99bead73fffb0c0f199695761908 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -61,6 +61,7 @@ impl ProjectSymbolsDelegate { } } + // Note if you make changes to this, also change `agent_ui::completion_provider::search_symbols` fn filter(&mut self, query: &str, window: &mut Window, cx: &mut Context>) { const MAX_MATCHES: usize = 100; let mut visible_matches = cx.background_executor().block(fuzzy::match_strings(