From dff2d59172fee1e9f995ece8fd0b4c57c36846fa Mon Sep 17 00:00:00 2001 From: pashpashpash Date: Fri, 28 Mar 2025 11:43:21 -0700 Subject: [PATCH] Updated feedback to model when diff edit fails (#2518) * updated feedback to model when diff edit fails * changeset * bias * typo * language --- .changeset/breezy-items-bake.md | 5 +++++ src/core/Cline.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/breezy-items-bake.md diff --git a/.changeset/breezy-items-bake.md b/.changeset/breezy-items-bake.md new file mode 100644 index 00000000..77f5427e --- /dev/null +++ b/.changeset/breezy-items-bake.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +improving search and replace edit failure behaviors diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 2f3f1fd0..53cfc4a7 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -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` + `\n${this.diffViewProvider.originalContent}\n\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()