Skip to content

Commit dff2d59

Browse files
authored
Updated feedback to model when diff edit fails (RooCodeInc#2518)
* updated feedback to model when diff edit fails * changeset * bias * typo * language
1 parent 9cb6cf5 commit dff2d59

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/breezy-items-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
improving search and replace edit failure behaviors

src/core/Cline.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,9 @@ export class Cline {
17541754
`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` +
17551755
`The file was reverted to its original state:\n\n` +
17561756
`<file_content path="${relPath.toPosix()}">\n${this.diffViewProvider.originalContent}\n</file_content>\n\n` +
1757-
`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.)`,
1757+
`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.` +
1758+
`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. ` +
1759+
`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)`,
17581760
),
17591761
)
17601762
await this.diffViewProvider.revertChanges()

0 commit comments

Comments
 (0)