{"draft":null,"from":232,"to":318,"files":[{"path":"src/engine/test/packed-files.test.ts","added":28,"removed":0,"diff":"--- a/src/engine/test/packed-files.test.ts\n+++ b/src/engine/test/packed-files.test.ts\n@@ -54,3 +54,31 @@\n \t\tstorage.db.close();\n \t}\n });\n+\n+test(\"a file's decoded history is kept between views and let go when an atom is added\", () => {\n+\tconst oracle = Repo.init({ \"a.txt\": lines(\"one\", \"two\", \"three\"), \"b.txt\": lines(\"bee\") });\n+\tconst storage = new SqlState();\n+\ttry {\n+\t\tconst graph = new Graph({ storage });\n+\t\tfor (const atom of oracle.graph.atoms()) graph.add(atom);\n+\t\tconst first = new View(graph, new StableOverlaySet(oracle.shared));\n+\t\tassert.equal(first.text(\"a.txt\"), \"one\\ntwo\\nthree\\n\");\n+\t\tassert.ok(graph.historyBytes > 0, \"the first layout keeps a.txt's history\");\n+\t\t// Another view of the same file reads only what its membership needs, not the history's pages again.\n+\t\tconst before = storage.reads;\n+\t\tassert.equal(new View(graph, new StableOverlaySet(oracle.shared)).sequence(\"a.txt\").length, 3);\n+\t\tconst pages = storage.reads - before;\n+\t\tconst cold = new Graph({ storage });\n+\t\tconst coldBefore = storage.reads;\n+\t\tnew View(cold, new StableOverlaySet(oracle.shared)).sequence(\"a.txt\");\n+\t\tassert.ok(pages < storage.reads - coldBefore, \"the kept history saved reads\");\n+\t\t// A new atom lets every kept history go; the next layout sees its lines.\n+\t\toracle.edit({ edits: [{ file: \"a.txt\", old: \"two\", new: \"TWO\" }] });\n+\t\tgraph.add(oracle.graph.atom([...oracle.shared].at(-1)!));\n+\t\tassert.equal(graph.historyBytes, 0);\n+\t\tconst after = new View(graph, new StableOverlaySet(oracle.shared));\n+\t\tassert.equal(after.text(\"a.txt\"), new View(oracle.graph, oracle.shared).text(\"a.txt\"));\n+\t} finally {\n+\t\tstorage.db.close();\n+\t}\n+});"}],"unmatched":[]}