{"draft":null,"from":102,"to":103,"files":[{"path":"src/engine/test/view.test.ts","added":78,"removed":0,"diff":"--- a/src/engine/test/view.test.ts\n+++ b/src/engine/test/view.test.ts\n@@ -91,4 +91,82 @@\n \t\tassert.deepEqual(view.knownPaths(), [\"a.txt\", \"b.txt\"]);\n \t\tassert.deepEqual(view.files(), { \"a.txt\": \"a\\n\" });\n \t});\n+\n+\tit(\"accounts for the membership bitmap before layout and stays observational\", () => {\n+\t\tconst small = Repo.init({ \"f.txt\": lines(\"same\") });\n+\t\tconst larger = Repo.init({ \"f.txt\": lines(\"same\") });\n+\t\tfor (let i = 0; i < 8; i++)\n+\t\t\tlarger.edit({ attrs: [{ file: \"f.txt\", name: \"exec\", value: i % 2 === 0 ? \"1\" : null }] });\n+\n+\t\tconst smallView = new View(small.graph, small.shared);\n+\t\tconst largerView = new View(larger.graph, larger.shared);\n+\t\tconst smallBeforeLayout = smallView.weight();\n+\t\tconst largerBeforeLayout = largerView.weight();\n+\t\tassert.ok(smallBeforeLayout >= small.graph.size);\n+\t\tassert.ok(largerBeforeLayout >= larger.graph.size);\n+\t\tassert.equal(largerBeforeLayout - smallBeforeLayout, larger.graph.size - small.graph.size);\n+\t\tassert.equal(largerView.weight(), largerBeforeLayout);\n+\n+\t\tassert.deepEqual(smallView.files(), largerView.files());\n+\t\tconst afterLayout = largerView.weight();\n+\t\tassert.equal(largerView.weight(), afterLayout);\n+\t\tassert.deepEqual(largerView.files(), { \"f.txt\": \"same\\n\" });\n+\t});\n+\n+\tit(\"accounts for lazy view-owned containers and relocation/index growth\", () => {\n+\t\tconst repo = Repo.init({ \"a.txt\": lines(\"one\", \"two\"), \"b.txt\": lines(\"base\") });\n+\t\trepo.edit({ move: { file: \"a.txt\", start: 0, end: 1, to: \"b.txt\", at: 1 } });\n+\t\tconst deletion = repo.edit({ edits: [{ file: \"b.txt\", old: \"base\\n\", new: \"\" }] });\n+\t\tconst view = repo.view();\n+\t\tlet weight = view.weight();\n+\t\tassert.equal(view.weight(), weight);\n+\n+\t\tassert.equal(view.set.size, 3);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tweight = view.weight();\n+\t\tassert.deepEqual(view.knownPaths(), [\"a.txt\", \"b.txt\"]);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tweight = view.weight();\n+\t\tassert.equal(view.fileOf(\"a0.0\"), \"b.txt\");\n+\t\tassert.ok(view.weight() > weight);\n+\n+\t\tconst expectedFiles = { \"a.txt\": \"two\\n\", \"b.txt\": \"one\\n\" };\n+\t\tassert.deepEqual(view.files(), expectedFiles);\n+\t\tweight = view.weight();\n+\t\tassert.deepEqual(\n+\t\t\tview.sequence(\"b.txt\").map((line) => [line.text, line.visible, line.deletedBy]),\n+\t\t\t[\n+\t\t\t\t[\"base\", false, [deletion.id]],\n+\t\t\t\t[\"one\", true, []],\n+\t\t\t],\n+\t\t);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tweight = view.weight();\n+\t\tassert.equal(view.sequenceIndex(\"b.txt\", \"a0.0\"), 1);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tweight = view.weight();\n+\t\tassert.equal(view.lineNumber(\"b.txt\", \"a0.0\"), 0);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tweight = view.weight();\n+\t\tassert.deepEqual(\n+\t\t\tview.lines(\"b.txt\").map((line) => line.text),\n+\t\t\t[\"one\"],\n+\t\t);\n+\t\tassert.ok(view.weight() > weight);\n+\t\tconst finalWeight = view.weight();\n+\t\tassert.equal(view.weight(), finalWeight);\n+\t\tassert.deepEqual(view.files(), expectedFiles);\n+\t});\n+\n+\tit(\"counts line-cache references without charging Graph-owned text per view\", () => {\n+\t\tconst short = Repo.init({ \"f.txt\": lines(\"x\") });\n+\t\tconst long = Repo.init({ \"f.txt\": lines(\"x\".repeat(10_000)) });\n+\t\tconst shortView = short.view();\n+\t\tconst longView = long.view();\n+\t\tshortView.lines(\"f.txt\");\n+\t\tlongView.lines(\"f.txt\");\n+\t\tassert.equal(shortView.weight(), longView.weight());\n+\t\tconst longWeight = longView.weight();\n+\t\tassert.equal(longView.weight(), longWeight);\n+\t});\n });"}],"unmatched":[]}