{"draft":null,"from":175,"to":318,"files":[{"path":"worker/project/definition-code.ts","added":21,"removed":1,"diff":"--- a/worker/project/definition-code.ts\n+++ b/worker/project/definition-code.ts\n@@ -2,11 +2,31 @@\n import { StoredText } from \"../../src/engine/stored-text.ts\";\n import { eachCodeLine } from \"./names.ts\";\n \n+/**\n+ * Characters of parsed code kept in memory before the rest goes to scratch (abso Capacity). The visible lines it is\n+ * parsed from are already in memory, so this at most doubles a file's text for the call; at 64 KB, every large file's\n+ * code went row by row into scratch and back, 25,000 rows each for abso's index.ts, a third of a cold collisions call.\n+ */\n+export const DEFINITION_CODE_IN_MEMORY = 4_000_000;\n+\n+let inMemoryLimit = DEFINITION_CODE_IN_MEMORY;\n+\n+/**\n+ * Tests only: the in-memory limit for every later call, so a small file takes the scratch path (abso's kept-reader\n+ * test checks scratch is let go). Answers the limit it replaces, to put back.\n+ */\n+export function setDefinitionCodeInMemory(limit: number): number {\n+\tconst before = inMemoryLimit;\n+\tinMemoryLimit = limit;\n+\treturn before;\n+}\n+\n /** Parsed code is temporary derived data, discarded with the scratch transaction. */\n export function withDefinitionCode<T>(\n \tview: ReadView,\n \tvisible: readonly VisibleLine[],\n \toperation: (code: readonly string[]) => T,\n+\tinMemory = inMemoryLimit,\n ): T {\n \tfunction* source() {\n \t\tfor (const line of visible) yield line.text;\n@@ -16,7 +36,7 @@\n \tlet prefix: string[] = [];\n \tlet size = 0;\n \tlet pending = iterator.next();\n-\twhile (!pending.done && size + pending.value.length + 1 <= 65536) {\n+\twhile (!pending.done && size + pending.value.length + 1 <= inMemory) {\n \t\tprefix.push(pending.value);\n \t\tsize += pending.value.length + 1;\n \t\tpending = iterator.next();"}],"unmatched":[]}