From 78091fa91ee52a5ada8f3e5b318f848bd3d5e237 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 17 Jun 2024 13:53:52 +0200 Subject: [PATCH] Don't include prompt titles / "Default Prompt:" in slash command output (#13139) This only includes a newline to ensure there's always something to fold. Release Notes: - N/A --- crates/assistant/src/slash_command/default_command.rs | 6 +++++- crates/assistant/src/slash_command/prompt_command.rs | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/assistant/src/slash_command/default_command.rs b/crates/assistant/src/slash_command/default_command.rs index 56c3a44997..bd26b724c9 100644 --- a/crates/assistant/src/slash_command/default_command.rs +++ b/crates/assistant/src/slash_command/default_command.rs @@ -53,7 +53,7 @@ impl SlashCommand for DefaultSlashCommand { let prompts = store.default_prompt_metadata(); let mut text = String::new(); - writeln!(text, "Default Prompt:").unwrap(); + text.push('\n'); for prompt in prompts { if let Some(title) = prompt.title { writeln!(text, "/prompt {}", title).unwrap(); @@ -61,6 +61,10 @@ impl SlashCommand for DefaultSlashCommand { } text.pop(); + if text.is_empty() { + text.push('\n'); + } + Ok(SlashCommandOutput { sections: vec![SlashCommandOutputSection { range: 0..text.len(), diff --git a/crates/assistant/src/slash_command/prompt_command.rs b/crates/assistant/src/slash_command/prompt_command.rs index 3e3041e170..21e22fd837 100644 --- a/crates/assistant/src/slash_command/prompt_command.rs +++ b/crates/assistant/src/slash_command/prompt_command.rs @@ -69,7 +69,10 @@ impl SlashCommand for PromptSlashCommand { } }); cx.foreground_executor().spawn(async move { - let prompt = prompt.await?; + let mut prompt = prompt.await?; + if prompt.is_empty() { + prompt.push('\n'); + } let range = 0..prompt.len(); Ok(SlashCommandOutput { text: prompt,