Updated feedback to model when diff edit fails (#2518)

* updated feedback to model when diff edit fails

* changeset

* bias

* typo

* language
This commit is contained in:
pashpashpash authored and GitHub committed 2025-03-28 11:43:21 -07:00
1 parent 9cb6cf52fc
commit dff2d59172
2 files changed
+8 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
improving search and replace edit failure behaviors
+3 -1
View File
@@ -1754,7 +1754,9 @@ export class Cline {
`This is likely because the SEARCH block content doesn't match exactly with what's in the file, or if you used multiple SEARCH/REPLACE blocks they may not have been in the order they appear in the file.\n\n` +
`The file was reverted to its original state:\n\n` +
`<file_content path="${relPath.toPosix()}">\n${this.diffViewProvider.originalContent}\n</file_content>\n\n` +
`Try again with fewer/more precise SEARCH blocks.\n(If you run into this error two times in a row, you may use the write_to_file tool as a fallback.)`,
`First, make sure you call the read_file tool and re-read the file again in case any changes were made, to get its latest state. Then, make a proper, TARGETED search and replace edit using the write_to_file tool.` +
`You may want to try fewer/more precise SEARCH blocks.\n(If you run into this error three times in a row, you may use the write_to_file tool as a fallback. ` +
`Keep in mind, the write_to_file fallback is far from ideal, as this means you'll be re-writing the entire contents of the file just to make a few edits, which takes time and money. So let's bias towards using replace_in_file as effectively as possible)`,
),
)
await this.diffViewProvider.revertChanges()