From 4a1a03223608add8eaff4391de4d5ff2390ff3a3 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Wed, 28 Oct 2026 13:34:34 +0000 Subject: [PATCH] test: History diff counts lines added in the newer version as added Anthony saw "6 lines removed" on a version that added 6. The diff direction is right; the old pre-sync text sorted above the save (fixed in 0.26.1), so the top version was diffed against the newer one. This pins the direction. Co-Authored-By: Claude Opus 5.5 --- test/diff.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/diff.test.ts b/test/diff.test.ts index f32f632..a5b8167 100644 --- a/test/diff.test.ts +++ b/test/diff.test.ts @@ -49,3 +49,13 @@ test("snippets mark lines and stop at the limit", () => { assert.deepEqual(snippet(diff, 3), ["- b", "- c", "+ B"]); assert.equal(snippet(diffLines("", "x".repeat(300)))[0]!.length, 120); }); + +test("lines added in the newer version count as added, not removed", () => { + // The history panel diffs each version against the one below it (older, newer). + const older = "one\ntwo\n"; + const newer = "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\n"; + const diff = diffLines(older, newer); + assert.equal(diff.added, 6); + assert.equal(diff.removed, 0); + assert.ok(snippet(diff, 8).every((line) => line.startsWith("+ "))); +});