fix(diff): preserve collapsed EOF marker
This commit is contained in:
@@ -114,6 +114,22 @@ describe("computeDiffLines", () => {
|
||||
expect(lines.filter((l) => l.kind === "hunk")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("preserves the EOF marker when a long unterminated trailing run collapses", () => {
|
||||
const trailing = Array.from({ length: 10 }, (_, i) => `t${i}`);
|
||||
const oldText = ["OLD", ...trailing].join("\n");
|
||||
const newText = ["NEW", ...trailing].join("\n");
|
||||
|
||||
expect(texts(computeDiffLines(oldText, newText))).toEqual([
|
||||
["del", "OLD"],
|
||||
["add", "NEW"],
|
||||
["ctx", "t0"],
|
||||
["ctx", "t1"],
|
||||
["ctx", "t2"],
|
||||
["hunk", "⋯ 7 unchanged lines ⋯"],
|
||||
["eof", "\\ No newline at end of file"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("produces one hunk for the long middle run, none for the short edges", () => {
|
||||
// Edge runs (2 lines) fit within their one-sided 3-line context budget;
|
||||
// only the interior run (10 lines, budgeted 3+3=6) needs to collapse.
|
||||
|
||||
Reference in New Issue
Block a user