Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant: Improve UI feedback when inserting `/delta` without new changes (#20356)

Danilo Leal37366ac90779
diff --git a/crates/assistant/src/slash_command/delta_command.rs b/crates/assistant/src/slash_command/delta_command.rs
index 5c8bc2b0230..f854bd5fdfb 100644
--- a/crates/assistant/src/slash_command/delta_command.rs
+++ b/crates/assistant/src/slash_command/delta_command.rs
@@ -58,6 +58,7 @@ impl SlashCommand for DeltaSlashCommand {
let mut paths = HashSet::default();
let mut file_command_old_outputs = Vec::new();
let mut file_command_new_outputs = Vec::new();
+
for section in context_slash_command_output_sections.iter().rev() {
if let Some(metadata) = section
.metadata
@@ -84,6 +85,7 @@ impl SlashCommand for DeltaSlashCommand {
cx.background_executor().spawn(async move {
let mut output = SlashCommandOutput::default();
+ let mut changes_detected = false;
let file_command_new_outputs = future::join_all(file_command_new_outputs).await;
for (old_text, new_output) in file_command_old_outputs
@@ -96,6 +98,7 @@ impl SlashCommand for DeltaSlashCommand {
if let Some(file_command_range) = new_output.sections.first() {
let new_text = &new_output.text[file_command_range.range.clone()];
if old_text.chars().ne(new_text.chars()) {
+ changes_detected = true;
output.sections.extend(new_output.sections.into_iter().map(
|section| SlashCommandOutputSection {
range: output.text.len() + section.range.start
@@ -112,6 +115,10 @@ impl SlashCommand for DeltaSlashCommand {
}
}
+ if !changes_detected {
+ return Err(anyhow!("no new changes detected"));
+ }
+
Ok(output.to_event_stream())
})
}