mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-06 02:47:56 +00:00
fix: reject apply_diff when search matches replace content
Prevents attempting to apply diffs where search and replace content are identical, which would result in no changes being made. Instead, provide a helpful error message explaining why the operation was rejected. Fixes: #1350 Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit is contained in:
parent
1b8bac66fd
commit
c7321b0107
1 changed files with 13 additions and 0 deletions
|
|
@ -275,6 +275,19 @@ Only use a single line of '=======' between search and replacement content, beca
|
|||
replaceContent = stripLineNumbers(replaceContent)
|
||||
}
|
||||
|
||||
// Validate that search and replace content are not identical
|
||||
if (searchContent === replaceContent) {
|
||||
diffResults.push({
|
||||
success: false,
|
||||
error:
|
||||
`Search and replace content are identical - no changes would be made\n\n` +
|
||||
`Debug Info:\n` +
|
||||
`- Search and replace must be different to make changes\n` +
|
||||
`- Use read_file to verify the content you want to change`,
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
// Split content into lines, handling both \n and \r\n
|
||||
const searchLines = searchContent === "" ? [] : searchContent.split(/\r?\n/)
|
||||
const replaceLines = replaceContent === "" ? [] : replaceContent.split(/\r?\n/)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue