Skip to content

Commit f990d1f

Browse files
committed
test(agents): cover edits through production line endings
1 parent 35e9a24 commit f990d1f

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎src/agents/sessions/tools/edit-diff.test.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { describe, expect, it } from "vitest";
2-
import { normalizeToLF } from "../../line-endings.js";
3-
import { applyEditsToNormalizedContent, generateDiffString } from "./edit-diff.js";
2+
import { applyEditsPreservingLineEndings, generateDiffString } from "./edit-diff.js";
43

54
function getMismatchMessage(
65
content: string,
76
edits: Array<{ oldText: string; newText: string }>,
87
): string {
98
try {
10-
applyEditsToNormalizedContent(normalizeToLF(content), edits, "test.ts");
9+
applyEditsPreservingLineEndings(content, edits, "test.ts");
1110
} catch (error) {
1211
return error instanceof Error ? error.message : String(error);
1312
}
@@ -142,8 +141,8 @@ describe("applyEditsToNormalizedContent uniqueness", () => {
142141
it("replaces an exactly unique match when trailing whitespace makes a sibling line fuzzy-identical", () => {
143142
const content = "foo(); \nfoo();\nbar();\n";
144143

145-
const result = applyEditsToNormalizedContent(
146-
normalizeToLF(content),
144+
const result = applyEditsPreservingLineEndings(
145+
content,
147146
[{ oldText: "foo();\n", newText: "baz();\n" }],
148147
"test.ts",
149148
);
@@ -157,8 +156,8 @@ describe("applyEditsToNormalizedContent fuzzy uniqueness", () => {
157156
const content = "foo(); \nfoo();\t\nbar();\n";
158157

159158
expect(() =>
160-
applyEditsToNormalizedContent(
161-
normalizeToLF(content),
159+
applyEditsPreservingLineEndings(
160+
content,
162161
[{ oldText: "foo();\n", newText: "baz();\n" }],
163162
"test.ts",
164163
),

‎src/agents/sessions/tools/edit-diff.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function applyEdits(normalizedContent: string, edits: Edit[], path: string): App
423423
};
424424
}
425425

426-
export function applyEditsToNormalizedContent(
426+
function applyEditsToNormalizedContent(
427427
normalizedContent: string,
428428
edits: Edit[],
429429
path: string,

0 commit comments

Comments
 (0)