{"draft":null,"from":164,"to":318,"files":[{"path":"src/engine/experimental/projection-reader.ts","added":70,"removed":3,"diff":"--- a/src/engine/experimental/projection-reader.ts\n+++ b/src/engine/experimental/projection-reader.ts\n@@ -1,6 +1,5 @@\n import { startNode } from \"../keys.ts\";\n import { StableSet } from \"../state-source.ts\";\n-import { joinLines } from \"../text.ts\";\n import type { FileAttrs, ReadView, SeqLine, VisibleLine } from \"../view.ts\";\n import type { ExperimentalMarkerProjection, MarkerState } from \"./projection-marker.ts\";\n \n@@ -74,7 +73,14 @@\n \t}\n \tlineNumber(path: string, line: string): number {\n \t\tthis.#assertLive();\n-\t\treturn this.lines(path).findIndex((item) => item.id === line);\n+\t\tlet index = 0;\n+\t\tfor (const id of this.#adapter.lineIds(this.#state, path)) {\n+\t\t\tthis.#assertLive();\n+\t\t\tif (id === line) return index;\n+\t\t\tindex++;\n+\t\t}\n+\t\tthis.#assertLive();\n+\t\treturn -1;\n \t}\n \tsameText(path: string, other: ReadView): boolean {\n \t\tthis.#assertLive();\n@@ -104,6 +110,30 @@\n \t\tfor (const id of this.graph.movers()) if (this.set.has(id)) return true;\n \t\treturn false;\n \t}\n+\t*#textChunks(n: number): IterableIterator<string> {\n+\t\tthis.#assertLive();\n+\t\tconst iterator = this.graph.textChunks(n);\n+\t\twhile (true) {\n+\t\t\tthis.#assertLive();\n+\t\t\tconst next = iterator.next();\n+\t\t\tthis.#assertLive();\n+\t\t\tif (next.done) return;\n+\t\t\tyield next.value;\n+\t\t}\n+\t}\n+\t*lineChunks(path: string): IterableIterator<() => Iterable<string>> {\n+\t\tthis.#assertLive();\n+\t\tconst iterator = this.#adapter.lineIds(this.#state, path);\n+\t\twhile (true) {\n+\t\t\tthis.#assertLive();\n+\t\t\tconst next = iterator.next();\n+\t\t\tthis.#assertLive();\n+\t\t\tif (next.done) return;\n+\t\t\tconst n = this.graph.lineN(next.value);\n+\t\t\tyield () => this.#textChunks(n);\n+\t\t}\n+\t}\n+\n \t*visibleLines(path: string): IterableIterator<VisibleLine> {\n \t\tthis.#assertLive();\n \t\tconst graph = this.#adapter.graph;\n@@ -122,6 +152,34 @@\n \t\tthis.#assertLive();\n \t\treturn [...this.visibleLines(path)];\n \t}\n+\t*#buildingLines(path: string): IterableIterator<VisibleLine> {\n+\t\tthis.#assertLive();\n+\t\tconst graph = this.#adapter.graph;\n+\t\tconst iterator = this.#adapter.lineIds(this.#state, path);\n+\t\twhile (true) {\n+\t\t\tthis.#assertLive();\n+\t\t\tconst next = iterator.next();\n+\t\t\tthis.#assertLive();\n+\t\t\tif (next.done) return;\n+\t\t\tconst id = next.value;\n+\t\t\tconst n = graph.lineN(id);\n+\t\t\tconst assertLive = () => this.#assertLive();\n+\t\t\tyield {\n+\t\t\t\tid,\n+\t\t\t\ttextChunks: () => this.#textChunks(n),\n+\t\t\t\tget text() {\n+\t\t\t\t\tassertLive();\n+\t\t\t\t\treturn graph.textOf(n);\n+\t\t\t\t},\n+\t\t\t\tatom: graph.idOfSeq(graph.writerSeqOf(n)),\n+\t\t\t};\n+\t\t}\n+\t}\n+\tbuildLines(path: string): readonly VisibleLine[] {\n+\t\tthis.#assertLive();\n+\t\treturn [...this.#buildingLines(path)];\n+\t}\n+\n \tsequence(path: string): readonly SeqLine[] {\n \t\tthis.#assertLive();\n \t\tconst adapter = this.#adapter,\n@@ -193,7 +251,16 @@\n \t}\n \ttext(path: string): string {\n \t\tthis.#assertLive();\n-\t\treturn joinLines([...this.visibleLines(path)].map((line) => line.text));\n+\t\tlet text = \"\",\n+\t\t\tpart = \"\";\n+\t\tfor (const line of this.visibleLines(path)) {\n+\t\t\tpart += `${line.text}\\n`;\n+\t\t\tif (part.length >= 16384) {\n+\t\t\t\ttext += part;\n+\t\t\t\tpart = \"\";\n+\t\t\t}\n+\t\t}\n+\t\treturn text + part;\n \t}\n \thasFile(path: string): boolean {\n \t\tthis.#assertLive();"}],"unmatched":[]}