Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Display default prompts more elaborately (#16471)
Kirill Bulatov69aae2037d5b
diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex 9b4a8e2e242..8e6a7d364e8 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -1808,7 +1808,7 @@ impl ContextEditor {};this.update_message_headers(cx);this.update_image_blocks(cx);- this.insert_slash_command_output_sections(sections, cx);+ this.insert_slash_command_output_sections(sections, false, cx);this}@@ -1821,7 +1821,7 @@ impl ContextEditor {let command = self.context.update(cx, |context, cx| {let first_message_id = context.messages(cx).next().unwrap().id;context.update_metadata(first_message_id, cx, |metadata| {- metadata.role = Role::System;+ metadata.role = Role::User;});context.reparse_slash_commands(cx);context.pending_slash_commands()[0].clone()@@ -1832,6 +1832,7 @@ impl ContextEditor {&command.name,&command.arguments,false,+ true,self.workspace.clone(),cx,);@@ -2098,6 +2099,7 @@ impl ContextEditor {&command.name,&command.arguments,true,+ false,workspace.clone(),cx,);@@ -2106,19 +2108,27 @@ impl ContextEditor {}}+ #[allow(clippy::too_many_arguments)]pub fn run_command(&mut self,command_range: Range<language::Anchor>,name: &str,arguments: &[String],ensure_trailing_newline: bool,+ expand_result: bool,workspace: WeakView<Workspace>,cx: &mut ViewContext<Self>,) {if let Some(command) = SlashCommandRegistry::global(cx).command(name) {let output = command.run(arguments, workspace, self.lsp_adapter_delegate.clone(), cx);self.context.update(cx, |context, cx| {- context.insert_command_output(command_range, output, ensure_trailing_newline, cx)+ context.insert_command_output(+ command_range,+ output,+ ensure_trailing_newline,+ expand_result,+ cx,+ )});}}@@ -2204,6 +2214,7 @@ impl ContextEditor {&command.name,&command.arguments,false,+ false,workspace.clone(),cx,);@@ -2300,8 +2311,13 @@ impl ContextEditor {output_range,sections,run_commands_in_output,+ expand_result,} => {- self.insert_slash_command_output_sections(sections.iter().cloned(), cx);+ self.insert_slash_command_output_sections(+ sections.iter().cloned(),+ *expand_result,+ cx,+ );if *run_commands_in_output {let commands = self.context.update(cx, |context, cx| {@@ -2317,6 +2333,7 @@ impl ContextEditor {&command.name,&command.arguments,false,+ false,self.workspace.clone(),cx,);@@ -2333,6 +2350,7 @@ impl ContextEditor {fn insert_slash_command_output_sections(&mut self,sections: impl IntoIterator<Item = SlashCommandOutputSection<language::Anchor>>,+ expand_result: bool,cx: &mut ViewContext<Self>,) {self.editor.update(cx, |editor, cx| {@@ -2387,6 +2405,9 @@ impl ContextEditor {editor.insert_creases(creases, cx);+ if expand_result {+ buffer_rows_to_fold.clear();+ }for buffer_row in buffer_rows_to_fold.into_iter().rev() {editor.fold_at(&FoldAt { buffer_row }, cx);}diff --git a/crates/assistant/src/context.rs b/crates/assistant/src/context.rsindex 4608c5df4b2..f68cdb53eb2 100644--- a/crates/assistant/src/context.rs+++ b/crates/assistant/src/context.rs@@ -295,6 +295,7 @@ pub enum ContextEvent {output_range: Range<language::Anchor>,sections: Vec<SlashCommandOutputSection<language::Anchor>>,run_commands_in_output: bool,+ expand_result: bool,},Operation(ContextOperation),}@@ -774,6 +775,7 @@ impl Context {cx.emit(ContextEvent::SlashCommandFinished {output_range,sections,+ expand_result: false,run_commands_in_output: false,});}@@ -1396,6 +1398,7 @@ impl Context {command_range: Range<language::Anchor>,output: Task<Result<SlashCommandOutput>>,ensure_trailing_newline: bool,+ expand_result: bool,cx: &mut ModelContext<Self>,) {self.reparse_slash_commands(cx);@@ -1469,6 +1472,7 @@ impl Context {output_range,sections,run_commands_in_output: output.run_commands_in_text,+ expand_result,},)});diff --git a/crates/assistant/src/context/context_tests.rs b/crates/assistant/src/context/context_tests.rsindex 1f5b98c9306..4eb7b75a64e 100644--- a/crates/assistant/src/context/context_tests.rs+++ b/crates/assistant/src/context/context_tests.rs@@ -891,6 +891,7 @@ async fn test_random_context_collaboration(cx: &mut TestAppContext, mut rng: Stdrun_commands_in_text: false,})),true,+ false,cx,);});diff --git a/crates/assistant/src/slash_command.rs b/crates/assistant/src/slash_command.rsindex 667b11c7421..b1a97688b2b 100644--- a/crates/assistant/src/slash_command.rs+++ b/crates/assistant/src/slash_command.rs@@ -124,6 +124,7 @@ impl SlashCommandCompletionProvider {&command_name,&[],true,+ false,workspace.clone(),cx,);@@ -208,6 +209,7 @@ impl SlashCommandCompletionProvider {&command_name,&completed_arguments,true,+ false,workspace.clone(),cx,);