Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Return which files were touched in the edit tool (#26564)
Richard Feldman3131b0459f7f
diff --git a/crates/assistant_tools/src/edit_files_tool.rs b/crates/assistant_tools/src/edit_files_tool.rsindex 95875f51998..2ac698a775e 100644--- a/crates/assistant_tools/src/edit_files_tool.rs+++ b/crates/assistant_tools/src/edit_files_tool.rs@@ -12,6 +12,7 @@ use language_model::{use project::{Project, ProjectPath};use schemars::JsonSchema;use serde::{Deserialize, Serialize};+use std::fmt::Write;use std::sync::Arc;#[derive(Debug, Serialize, Deserialize, JsonSchema)]@@ -145,17 +146,29 @@ impl Tool for EditFilesTool {}}+ let mut answer = match changed_buffers.len() {+ 0 => "No files were edited.".to_string(),+ 1 => "Successfully edited ".to_string(),+ _ => "Successfully edited these files:\n\n".to_string(),+ };+// Save each buffer once at the endfor buffer in changed_buffers {project- .update(&mut cx, |project, cx| project.save_buffer(buffer, cx))?+ .update(&mut cx, |project, cx| {+ if let Some(file) = buffer.read(&cx).file() {+ let _ = write!(&mut answer, "{}\n\n", &file.path().display());+ }++ project.save_buffer(buffer, cx)+ })?.await?;}let errors = parser.errors();if errors.is_empty() {- Ok("Successfully applied all edits".into())+ Ok(answer.trim_end().to_string())} else {let error_message = errors.iter()