Changesets · Branches · Tags · Compare
| Changeset | 51b5b0f4d9423d8656a82eceec9ab66c66d91ab011c95c00ba1dd9d73d226fe8 |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-09-09 14:14 -07:00 |
| Committer | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-09-09 14:14 -07:00 |
| Parents | ad3929d81b86 |
2 files changed
modified extensions/vscode/src/diff/processDiff.ts +17 −8
| @@ -1,10 +1,11 @@ | ||
| 1 | 1 | import { Core } from "core/core"; |
| 2 | 2 | import { DataLogger } from "core/data/log"; |
| 3 | +import { myersDiff } from "core/diff/myers"; | |
| 3 | 4 | |
| 4 | 5 | import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; |
| 5 | 6 | import { editOutcomeTracker } from "../extension/EditOutcomeTracker"; |
| 6 | -import { createPrettyPatch, normalizeContent } from "../util/diffUtils"; | |
| 7 | 7 | import { VsCodeIde } from "../VsCodeIde"; |
| 8 | + | |
| 8 | 9 | import { VerticalDiffManager } from "./vertical/manager"; |
| 9 | 10 | |
| 10 | 11 | export async function processDiff( |
| @@ -62,16 +63,24 @@ | ||
| 62 | 63 | |
| 63 | 64 | // Detect autoformatting by comparing normalized content |
| 64 | 65 | let autoFormattingDiff: string | undefined; |
| 65 | - const normalizedPreSave = normalizeContent(preSaveContent); | |
| 66 | - const normalizedPostSave = normalizeContent(postSaveContent); | |
| 66 | + const normalizedPreSave = preSaveContent.trim(); | |
| 67 | + const normalizedPostSave = postSaveContent.trim(); | |
| 67 | 68 | |
| 68 | 69 | if (normalizedPreSave !== normalizedPostSave) { |
| 69 | 70 | // Auto-formatting was applied by the editor |
| 70 | - autoFormattingDiff = createPrettyPatch( | |
| 71 | - newOrCurrentUri, | |
| 72 | - preSaveContent, | |
| 73 | - postSaveContent, | |
| 74 | - ); | |
| 71 | + const diffLines = myersDiff(preSaveContent, postSaveContent); | |
| 72 | + autoFormattingDiff = diffLines | |
| 73 | + .map(line => { | |
| 74 | + switch (line.type) { | |
| 75 | + case "old": | |
| 76 | + return `-${line.line}`; | |
| 77 | + case "new": | |
| 78 | + return `+${line.line}`; | |
| 79 | + case "same": | |
| 80 | + return ` ${line.line}`; | |
| 81 | + } | |
| 82 | + }) | |
| 83 | + .join("\n"); | |
| 75 | 84 | } |
| 76 | 85 | |
| 77 | 86 | await sidebar.webviewProtocol.request("updateApplyState", { |
deleted extensions/vscode/src/util/diffUtils.ts +0 −41
| @@ -1,41 +0,0 @@ | ||
| 1 | -import { myersDiff } from "core/diff/myers"; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Creates a pretty patch diff string similar to unified diff format | |
| 5 | - * Uses Continue's existing myersDiff function for diff calculation | |
| 6 | - */ | |
| 7 | -export function createPrettyPatch( | |
| 8 | - filename: string = "file", | |
| 9 | - oldStr: string = "", | |
| 10 | - newStr: string = "", | |
| 11 | -): string { | |
| 12 | - if (oldStr === newStr) { | |
| 13 | - return ""; | |
| 14 | - } | |
| 15 | - | |
| 16 | - const diffLines = myersDiff(oldStr, newStr); | |
| 17 | - const patchLines: string[] = []; | |
| 18 | - | |
| 19 | - for (const diffLine of diffLines) { | |
| 20 | - switch (diffLine.type) { | |
| 21 | - case "old": | |
| 22 | - patchLines.push(`-${diffLine.line}`); | |
| 23 | - break; | |
| 24 | - case "new": | |
| 25 | - patchLines.push(`+${diffLine.line}`); | |
| 26 | - break; | |
| 27 | - case "same": | |
| 28 | - patchLines.push(` ${diffLine.line}`); | |
| 29 | - break; | |
| 30 | - } | |
| 31 | - } | |
| 32 | - | |
| 33 | - return patchLines.join("\n"); | |
| 34 | -} | |
| 35 | - | |
| 36 | -/** | |
| 37 | - * Normalizes content by trimming whitespace for comparison | |
| 38 | - */ | |
| 39 | -export function normalizeContent(content: string): string { | |
| 40 | - return content.trim(); | |
| 41 | -} | |
| No newline at the end of the file |