Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
acp: Hide completion menu when typing slash command argument (#40126)
Bennet Fennerda5f25d9b00c
diff --git a/crates/agent_ui/src/acp/completion_provider.rs b/crates/agent_ui/src/acp/completion_provider.rsindex 40ac1aae997..684b8f2d0d7 100644--- a/crates/agent_ui/src/acp/completion_provider.rs+++ b/crates/agent_ui/src/acp/completion_provider.rs@@ -775,7 +775,7 @@ impl CompletionProvider for ContextPickerCompletionProvider {}});}- is_missing_argument+ false}})),}@@ -910,6 +910,17 @@ impl CompletionProvider for ContextPickerCompletionProvider {offset_to_line,self.prompt_capabilities.borrow().embedded_context,)+ .filter(|completion| {+ // Right now we don't support completing arguments of slash commands+ let is_slash_command_with_argument = matches!(+ completion,+ ContextCompletion::SlashCommand(SlashCommandCompletion {+ argument: Some(_),+ ..+ })+ );+ !is_slash_command_with_argument+ }).map(|completion| {completion.source_range().start <= offset_to_line + position.column as usize&& completion.source_range().end >= offset_to_line + position.column as usizediff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rsindex d16e22b662a..4be30705e00 100644--- a/crates/agent_ui/src/acp/message_editor.rs+++ b/crates/agent_ui/src/acp/message_editor.rs@@ -2021,21 +2021,11 @@ mod tests {editor.update_in(&mut cx, |editor, _window, cx| {assert_eq!(editor.text(cx), "/say-hello ");assert_eq!(editor.display_text(cx), "/say-hello <name>");- assert!(editor.has_visible_completions_menu());-- assert_eq!(- current_completion_labels_with_documentation(editor),- &[("say-hello".into(), "Say hello to whoever you want".into())]- );+ assert!(!editor.has_visible_completions_menu());});cx.simulate_input("GPT5");- editor.update_in(&mut cx, |editor, window, cx| {- assert!(editor.has_visible_completions_menu());- editor.confirm_completion(&editor::actions::ConfirmCompletion::default(), window, cx);- });-cx.run_until_parked();editor.update_in(&mut cx, |editor, window, cx| {@@ -2044,7 +2034,7 @@ mod tests {assert!(!editor.has_visible_completions_menu());// Delete argument- for _ in 0..4 {+ for _ in 0..5 {editor.backspace(&editor::actions::Backspace, window, cx);}});@@ -2052,13 +2042,12 @@ mod tests {cx.run_until_parked();editor.update_in(&mut cx, |editor, window, cx| {- assert_eq!(editor.text(cx), "/say-hello ");+ assert_eq!(editor.text(cx), "/say-hello");// Hint is visible because argument was deletedassert_eq!(editor.display_text(cx), "/say-hello <name>");// Delete last command lettereditor.backspace(&editor::actions::Backspace, window, cx);- editor.backspace(&editor::actions::Backspace, window, cx);});cx.run_until_parked();