Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/core/tools/applyDiffTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,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()
Expand Down
16 changes: 15 additions & 1 deletion src/core/tools/multiApplyDiffTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,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)
Expand Down