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()