mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
feat: add efficiency warning for single SEARCH/REPLACE blocks in apply_diff (#6055)
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org> Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
This commit is contained in:
parent
02118c5e7f
commit
25857a4809
2 changed files with 24 additions and 3 deletions
|
|
@ -193,10 +193,17 @@ export async function applyDiffToolLegacy(
|
|||
// Get the formatted response message
|
||||
const message = await cline.diffViewProvider.pushToolWriteResult(cline, cline.cwd, !fileExists)
|
||||
|
||||
// Check for single SEARCH/REPLACE block warning
|
||||
const searchBlocks = (diffContent.match(/<<<<<<< SEARCH/g) || []).length
|
||||
const singleBlockNotice =
|
||||
searchBlocks === 1
|
||||
? "\n<notice>Making multiple related changes in a single apply_diff is more efficient. If other changes are needed in this file, please include them as additional SEARCH/REPLACE blocks.</notice>"
|
||||
: ""
|
||||
|
||||
if (partFailHint) {
|
||||
pushToolResult(partFailHint + message)
|
||||
pushToolResult(partFailHint + message + singleBlockNotice)
|
||||
} else {
|
||||
pushToolResult(message)
|
||||
pushToolResult(message + singleBlockNotice)
|
||||
}
|
||||
|
||||
await cline.diffViewProvider.reset()
|
||||
|
|
|
|||
|
|
@ -601,8 +601,22 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
|
|||
await cline.say("diff_error", allDiffErrors.join("\n"))
|
||||
}
|
||||
|
||||
// Check for single SEARCH/REPLACE block warning
|
||||
let totalSearchBlocks = 0
|
||||
for (const operation of operations) {
|
||||
for (const diffItem of operation.diff) {
|
||||
const searchBlocks = (diffItem.content.match(/<<<<<<< SEARCH/g) || []).length
|
||||
totalSearchBlocks += searchBlocks
|
||||
}
|
||||
}
|
||||
|
||||
const singleBlockNotice =
|
||||
totalSearchBlocks === 1
|
||||
? "\n<notice>Making multiple related changes in a single apply_diff is more efficient. If other changes are needed in this file, please include them as additional SEARCH/REPLACE blocks.</notice>"
|
||||
: ""
|
||||
|
||||
// Push the final result combining all operation results
|
||||
pushToolResult(results.join("\n\n"))
|
||||
pushToolResult(results.join("\n\n") + singleBlockNotice)
|
||||
return
|
||||
} catch (error) {
|
||||
await handleError("applying diff", error)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue