fix(diff): preserve collapsed EOF marker

This commit is contained in:
Miguel Palhas
2026-09-05 09:33:58 +01:00
parent f96f94db8f
commit eafeac5c05
3 changed files with 55 additions and 5 deletions
+5 -1
View File
@@ -130,10 +130,14 @@ function hunk(ops: Op[]): DiffLine[] {
run.forEach(push);
} else {
if (keepHead) run.slice(0, keepHead).forEach(push);
const collapsed = run.slice(keepHead, run.length - keepTail);
out.push({
kind: "hunk",
text: `⋯ ${run.length - keepHead - keepTail} unchanged lines ⋯`,
text: `⋯ ${collapsed.length} unchanged lines ⋯`,
});
if (collapsed.some((op) => !op.line.terminated)) {
out.push({ kind: "eof", text: "\\ No newline at end of file" });
}
if (keepTail) run.slice(run.length - keepTail).forEach(push);
}
i = j;