Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assistant find-replace: Fall back to replace_with_flexible_indent (#27795)
Agus Zubiagad51aa2ffb0a5
diff --git a/crates/assistant_tools/src/find_replace_file_tool.rs b/crates/assistant_tools/src/find_replace_file_tool.rsindex a637417cfab..725ae746d7c 100644--- a/crates/assistant_tools/src/find_replace_file_tool.rs+++ b/crates/assistant_tools/src/find_replace_file_tool.rs@@ -1,4 +1,4 @@-use crate::schema::json_schema_for;+use crate::{replace::replace_with_flexible_indent, schema::json_schema_for};use anyhow::{anyhow, Context as _, Result};use assistant_tool::{ActionLog, Tool};use gpui::{App, AppContext, Entity, Task};@@ -188,7 +188,11 @@ impl Tool for FindReplaceFileTool {let result = cx.background_spawn(async move {- replace_exact(&input.find, &input.replace, &snapshot).await+ // Try to match exactly+ replace_exact(&input.find, &input.replace, &snapshot)+ .await+ // If that fails, try being flexible about indentation+ .or_else(|| replace_with_flexible_indent(&input.find, &input.replace, &snapshot))}).await;