Skip to content

Commit 4693132

Browse files
committed
fix(tools): Generate unified diff for write_to_file in background editing mode
When PREVENT_FOCUS_DISRUPTION experiment is enabled, write_to_file was not generating a unified diff for existing files, causing the diff not to display in the chat view. Now generates the same diff format as non-background mode for consistency.
1 parent f7b99d5 commit 4693132

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/tools/writeToFileTool.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ export async function writeToFileTool(
204204

205205
const completeMessage = JSON.stringify({
206206
...sharedMessageProps,
207-
content: newContent,
207+
content: fileExists ? undefined : newContent,
208+
diff: fileExists
209+
? formatResponse.createPrettyPatch(relPath, cline.diffViewProvider.originalContent, newContent)
210+
: undefined,
208211
} satisfies ClineSayTool)
209212

210213
const didApprove = await askApproval("tool", completeMessage, undefined, isWriteProtected)

0 commit comments

Comments
 (0)