assistant find-replace: Fall back to replace_with_flexible_indent (#27795)

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-03-31 14:51:43 -03:00 committed by GitHub
parent d40b49ceb9
commit d51aa2ffb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;