diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index f5b4ab7dd3..41b0d77559 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -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 + ? "\nMaking 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." + : "" + if (partFailHint) { - pushToolResult(partFailHint + message) + pushToolResult(partFailHint + message + singleBlockNotice) } else { - pushToolResult(message) + pushToolResult(message + singleBlockNotice) } await cline.diffViewProvider.reset() diff --git a/src/core/tools/multiApplyDiffTool.ts b/src/core/tools/multiApplyDiffTool.ts index 8057f77949..d679eac332 100644 --- a/src/core/tools/multiApplyDiffTool.ts +++ b/src/core/tools/multiApplyDiffTool.ts @@ -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 + ? "\nMaking 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." + : "" + // 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)