From 494fc951ed1d12c023662e2d909c556dc647cb39 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Tue, 11 Nov 2025 13:22:34 -0700 Subject: [PATCH] diff view: normalize original buffer EOLs and force trailing newline for display; should remove single-line deletion in insert_content EOF append --- src/integrations/editor/DiffViewProvider.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index e19f275bef..eaff90896c 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -72,10 +72,10 @@ export class DiffViewProvider { if (fileExists) { this.originalContent = await fs.readFile(absolutePath, "utf-8") - // Normalize trailing newline for display only to avoid false replace of last line - this.originalContentForDisplay = this.originalContent.endsWith("\n") - ? this.originalContent - : this.originalContent + "\n" + // Normalize EOLs to \n for display and ensure a trailing newline so + // the last unchanged line is treated as context instead of a replace. + const normalizedEol = this.originalContent.replace(/\r\n/g, "\n") + this.originalContentForDisplay = normalizedEol.endsWith("\n") ? normalizedEol : normalizedEol + "\n" } else { this.originalContent = "" // For new files, keep original empty to show all additions