From 1f5389f070bb368badf3ed99a8ba02449078f181 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 9 Sep 2025 14:14:35 -0700 Subject: [PATCH] updates --- extensions/vscode/src/diff/processDiff.ts | 25 +++++++++----- extensions/vscode/src/util/diffUtils.ts | 41 ----------------------- 2 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 extensions/vscode/src/util/diffUtils.ts diff --git a/extensions/vscode/src/diff/processDiff.ts b/extensions/vscode/src/diff/processDiff.ts index d46b4ef9d..eda40e162 100644 --- a/extensions/vscode/src/diff/processDiff.ts +++ b/extensions/vscode/src/diff/processDiff.ts @@ -1,10 +1,11 @@ import { Core } from "core/core"; import { DataLogger } from "core/data/log"; +import { myersDiff } from "core/diff/myers"; import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; import { editOutcomeTracker } from "../extension/EditOutcomeTracker"; -import { createPrettyPatch, normalizeContent } from "../util/diffUtils"; import { VsCodeIde } from "../VsCodeIde"; + import { VerticalDiffManager } from "./vertical/manager"; export async function processDiff( @@ -62,16 +63,24 @@ export async function processDiff( // Detect autoformatting by comparing normalized content let autoFormattingDiff: string | undefined; - const normalizedPreSave = normalizeContent(preSaveContent); - const normalizedPostSave = normalizeContent(postSaveContent); + const normalizedPreSave = preSaveContent.trim(); + const normalizedPostSave = postSaveContent.trim(); if (normalizedPreSave !== normalizedPostSave) { // Auto-formatting was applied by the editor - autoFormattingDiff = createPrettyPatch( - newOrCurrentUri, - preSaveContent, - postSaveContent, - ); + const diffLines = myersDiff(preSaveContent, postSaveContent); + autoFormattingDiff = diffLines + .map(line => { + switch (line.type) { + case "old": + return `-${line.line}`; + case "new": + return `+${line.line}`; + case "same": + return ` ${line.line}`; + } + }) + .join("\n"); } await sidebar.webviewProtocol.request("updateApplyState", { diff --git a/extensions/vscode/src/util/diffUtils.ts b/extensions/vscode/src/util/diffUtils.ts deleted file mode 100644 index 4e53fb8c6..000000000 --- a/extensions/vscode/src/util/diffUtils.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { myersDiff } from "core/diff/myers"; - -/** - * Creates a pretty patch diff string similar to unified diff format - * Uses Continue's existing myersDiff function for diff calculation - */ -export function createPrettyPatch( - filename: string = "file", - oldStr: string = "", - newStr: string = "", -): string { - if (oldStr === newStr) { - return ""; - } - - const diffLines = myersDiff(oldStr, newStr); - const patchLines: string[] = []; - - for (const diffLine of diffLines) { - switch (diffLine.type) { - case "old": - patchLines.push(`-${diffLine.line}`); - break; - case "new": - patchLines.push(`+${diffLine.line}`); - break; - case "same": - patchLines.push(` ${diffLine.line}`); - break; - } - } - - return patchLines.join("\n"); -} - -/** - * Normalizes content by trimming whitespace for comparison - */ -export function normalizeContent(content: string): string { - return content.trim(); -} \ No newline at end of file