Elffuss BraidHub

kikocis/continue public

updates
Changeset51b5b0f4d9423d8656a82eceec9ab66c66d91ab011c95c00ba1dd9d73d226fe8
AuthorPatrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-09-09 14:14 -07:00
CommitterPatrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-09-09 14:14 -07:00
Parentsad3929d81b86

Browse the files at this changeset

2 files changed

modified extensions/vscode/src/diff/processDiff.ts +17 −8
@@ -1,10 +1,11 @@
11 import { Core } from "core/core";
22 import { DataLogger } from "core/data/log";
3+import { myersDiff } from "core/diff/myers";
34
45 import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider";
56 import { editOutcomeTracker } from "../extension/EditOutcomeTracker";
6-import { createPrettyPatch, normalizeContent } from "../util/diffUtils";
77 import { VsCodeIde } from "../VsCodeIde";
8+
89 import { VerticalDiffManager } from "./vertical/manager";
910
1011 export async function processDiff(
@@ -62,16 +63,24 @@
6263
6364 // Detect autoformatting by comparing normalized content
6465 let autoFormattingDiff: string | undefined;
65- const normalizedPreSave = normalizeContent(preSaveContent);
66- const normalizedPostSave = normalizeContent(postSaveContent);
66+ const normalizedPreSave = preSaveContent.trim();
67+ const normalizedPostSave = postSaveContent.trim();
6768
6869 if (normalizedPreSave !== normalizedPostSave) {
6970 // 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");
7584 }
7685
7786 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