{"draft":null,"from":115,"to":116,"files":[{"path":"src/engine/test/view.test.ts","added":26,"removed":0,"diff":"--- a/src/engine/test/view.test.ts\n+++ b/src/engine/test/view.test.ts\n@@ -8,6 +8,21 @@\n import { lines, Repo } from \"./helpers.ts\";\n \n describe(\"View\", () => {\n+\tit(\"reuses indexed membership across a long run of lines without a history-sized memo\", () => {\n+\t\tconst repo = Repo.init({ \"long.txt\": \"line\\n\".repeat(1000) });\n+\t\tclass CountingSet extends StableOverlaySet<AtomId> {\n+\t\t\tcalls = 0;\n+\t\t\toverride has(id: AtomId): boolean {\n+\t\t\t\tthis.calls++;\n+\t\t\t\treturn super.has(id);\n+\t\t\t}\n+\t\t}\n+\t\tconst set = new CountingSet([\"a0\"]);\n+\t\tconst view = new View(repo.graph, set);\n+\t\tset.calls = 0;\n+\t\tassert.equal(view.text(\"long.txt\"), \"line\\n\".repeat(1000));\n+\t\tassert.ok(set.calls <= 2, `membership was queried ${set.calls} times for one atom`);\n+\t});\n \tit(\"immutable indexed membership avoids a history-sized bitmap and remains a snapshot\", () => {\n \t\tclass RangeMembership extends StableSet<AtomId> {\n \t\t\treadonly retainedBytes = 64;\n@@ -41,6 +56,17 @@\n \t\tassert.equal(first.set.has(\"a80\"), false);\n \t\tassert.throws(() => new View(repo.graph, new StableOverlaySet<AtomId>([\"a1\"])), /not closed/);\n \t});\n+\tit(\"membership memo collisions preserve both included and excluded historical atoms\", () => {\n+\t\tconst repo = Repo.init({ \"f.txt\": \"0\\n\" });\n+\t\tfor (let i = 1; i <= 257; i++) repo.edit({ edits: [{ file: \"f.txt\", old: `${i - 1}\\n`, new: `${i}\\n` }] });\n+\t\tconst old = new View(repo.graph, new StableOverlaySet<AtomId>([\"a0\"]));\n+\t\tassert.equal(old.text(\"f.txt\"), \"0\\n\");\n+\t\tassert.deepEqual(\n+\t\t\told.sequence(\"f.txt\").map((line) => line.text),\n+\t\t\t[\"0\"],\n+\t\t);\n+\t\tassert.equal(repo.view().text(\"f.txt\"), \"257\\n\");\n+\t});\n \tit(\"keeps deleted lines as tombstones in the full sequence\", () => {\n \t\tconst repo = Repo.init({ \"f.txt\": lines(\"one\", \"two\", \"three\") });\n \t\tconst del = repo.edit({ edits: [{ file: \"f.txt\", old: \"two\\n\", new: \"\" }] });"}],"unmatched":[]}