Skip to content

fix(muya): remove the quadratic costs that freeze large documents (#4887) - #4942

Merged
Jocs merged 8 commits into
marktext:developfrom
Renakoni:fix/large-document-open-freeze
Oct 22, 2026
Merged

Jocs merged 8 commits into
marktext:developfrom
Renakoni:fix/large-document-open-freeze

Conversation

@Renakoni

@Renakoni Renakoni commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Addresses two repeated-work costs behind large-document freezes in #4887: reference definitions were re-collected for every rendered block, and Marked token walking repeatedly concatenated an ever-growing result array. This revision caches definitions by JSON-state revision and uses a linear-result token walker in parsing, HTML/export highlighting, and clipboard HTML.

State ownership and review changes

Updated through 21418d13, rebased on develop 7f8de798 in response to Jocs's review.

  • Remove the recursive/shallow cloneStateTree and use develop's existing iterative deepClone. Preserve isolation for array-valued metadata, input JSON, inserted OT values, and public snapshots.
  • Collect reference definitions from the complete state through an internal read-only accessor, without cloning for collection. Use iterative traversal and cache by revision.
  • Keep public doc and prevDoc as memoized defensive snapshots pinned to the event. History reads the pre-apply root through a private WeakMap association, so internal history recording does not force a public full-document clone. Copy-on-write still shares untouched subtrees: returning the raw root to mutable public listeners would break isolation.
  • Return early for operation batches that compose to null; flush pending edits before undo/redo stack checks.
  • Preserve Marked traversal order/identity, custom childTokens, callback context/results, and synchronous/asynchronous highlighting across all three entrypoints.
  • Remove the double-rAF test settle and duplicate wait. Add a real typing-to-source-mode regression without an added frame wait, and correct snapshot/cache documentation and test cleanup.

This removes specific repeated work, not every whole-document cost. Hosts that request complete state/Markdown and per-revision reference collection still perform whole-document work.

Validation

At 21418d13: 1876 Muya unit tests, 1347 Markdown specification tests, TypeScript, scoped ESLint, circular dependency check, Muya/desktop builds, and 10 Electron tests passed locally. The final review reran the snapshot, reference-cache, Marked-walker, and pending-history suites: 19 tests passed.

The typing regression verifies the tested Windows/Electron path; it does not establish that every platform or un-dispatched-input timing race is fixed. No test-only frame delay remains.

The earlier 605 KB / 2.1 MB measurements belong to an older revision; the multi-minute baseline figures were extrapolations. They are not first-paint or input-latency measurements of this revision. A new same-machine, single-sample comparison supports the algorithmic improvement across multiple shapes, but is not a stable benchmark.

Follow-up and provenance

#4946 builds on this revision for progressive DOM mounting and consumer contracts. It reuses this PR's state ownership and History changes. Single giant containers and synchronous full-tree consumers remain outside the responsiveness guarantee; neither PR is a claim to resolve every case in #4887.

The original profiling and fixes came from the Android port, Renakoni/marktext-android#124. This revision incorporates the upstream review and develop's subsequent changes.

@Renakoni Renakoni changed the title fix(muya): stop re-collecting reference definitions per rendered block (#4887) fix(muya): open large documents without freezing (#4887) Jul 16, 2026
@Renakoni
Renakoni force-pushed the fix/large-document-open-freeze branch from 8902418 to 4b130e9 Compare July 16, 2026 06:41
@Renakoni Renakoni changed the title fix(muya): open large documents without freezing (#4887) fix(muya): remove the quadratic costs that freeze large documents (#4887) Jul 16, 2026
@Renakoni
Renakoni force-pushed the fix/large-document-open-freeze branch 2 times, most recently from 6f8f93e to 03d6ca7 Compare July 16, 2026 08:48
niyo-oyin added a commit to niyo-oyin/marktext-ja that referenced this pull request Jul 29, 2026
- PR marktext#4946 (includes its base PR marktext#4942): removes the quadratic costs
  that froze large documents and mounts them progressively — a 2.1 MB
  document goes from an indefinite freeze to interactive in seconds.
  Applied verbatim; upstream review addressed 19 findings with 31
  regression tests, all passing here.
- PR marktext#4931 (marktext#4926): deleting at an offset inside a surrogate pair left
  a lone surrogate that crashed text-unicode ("Invalid offset - splits
  unicode bytes"). The content.ts hunk conflicted with our Phase 1
  isComposed guards and was integrated by hand; the new cursor snap
  additionally runs only when no IME composition is open, since moving
  the DOM selection mid-composition would detach the IME anchor.
- PR marktext#4913 (marktext#4899): Shift+Tab outdent with trailing sibling blocks
  corrupted the state tree (paragraphs appended directly into a list),
  crashing the next composed op. muya hunks only — the PR's legacy
  muyajs hunks target the removed engine.
- PR marktext#4911 skipped: the equivalent detached-block guard already exists
  in @muyajs/core's language selector (marktext#4654), verified in source.
- PR marktext#4930 (marktext#4921): CodeMirror instance wrapped in a Vue proxy broke
  source-code mode; markRaw fix applied cleanly.

muya suite 1515/1515, tsc/eslint/madge clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ef4yFuXFbyKNTazkwUtygY
niyo-oyin added a commit to niyo-oyin/marktext-ja that referenced this pull request Jul 29, 2026
- PR marktext#4946 (includes its base PR marktext#4942): removes the quadratic costs
  that froze large documents and mounts them progressively — a 2.1 MB
  document goes from an indefinite freeze to interactive in seconds.
  Applied verbatim; upstream review addressed 19 findings with 31
  regression tests, all passing here.
- PR marktext#4931 (marktext#4926): deleting at an offset inside a surrogate pair left
  a lone surrogate that crashed text-unicode ("Invalid offset - splits
  unicode bytes"). The content.ts hunk conflicted with our Phase 1
  isComposed guards and was integrated by hand; the new cursor snap
  additionally runs only when no IME composition is open, since moving
  the DOM selection mid-composition would detach the IME anchor.
- PR marktext#4913 (marktext#4899): Shift+Tab outdent with trailing sibling blocks
  corrupted the state tree (paragraphs appended directly into a list),
  crashing the next composed op. muya hunks only — the PR's legacy
  muyajs hunks target the removed engine.
- PR marktext#4911 skipped: the equivalent detached-block guard already exists
  in @muyajs/core's language selector (marktext#4654), verified in source.
- PR marktext#4930 (marktext#4921): CodeMirror instance wrapped in a Vue proxy broke
  source-code mode; markRaw fix applied cleanly.

muya suite 1515/1515, tsc/eslint/madge clean.
@xyasharx

Copy link
Copy Markdown

Hi maintainers,
Thank you @Renakoni @Jocs for working on this! This issue (#4887) is currently a major blocker for many of us working with large documents, and this PR seems to be a solid fix.
It would be amazing if the team could review and merge this when possible. Really looking forward to having this improvement in the next release! 🙏

@Jocs

Jocs commented Sep 18, 2026

Copy link
Copy Markdown
Member

Thanks for this — the profiling work is excellent and both root causes are correctly identified. The reference-definition cache in particular is a clean fix for a genuinely quadratic path, and the before/after numbers are the kind of evidence I wish every perf PR came with.

Before it can land, though, there's one thing that needs flagging up front, because it changes the shape of the whole first fix:

The cloneStateTree rationale has gone stale

cloneState.ts justifies itself as avoiding "the high fixed cost of structuredClone". That was true when you wrote it — but it isn't any more:

This PR opened 2026-07-16
deepClone at that time export function deepClone<T>(value: T): T { return structuredClone(value) }
deepClone rewritten 2026-09-07, 8b94f6f9 — fix(muya): #4747 deep clone editor state without recursing (#5259)

#5259 replaced structuredClone with an explicit-stack iterative walk. structuredClone is now only reached for values that are neither arrays nor plain objects (Date, Map, typed arrays) — and the document state schema contains none of those. The cost cloneStateTree was written to avoid is already gone from deepClone.

This matters because cloneStateTree reintroduces two bugs that deepClone doesn't have.


Blocking

1. cloneStateTree is recursive — this regresses the stack overflow fixed by #4747 / #5259

packages/muya/src/state/cloneState.ts:11

getState() moves off the iterative deepClone onto a recursive clone. deepClone's own doc comment spells out why that's not safe:

Arrays and plain objects are walked with an explicit stack, so the nesting depth of the input never consumes engine stack: structuredClone recurses once per level and throws RangeError on a bullet list a few hundred levels deep, which is still ordinary Markdown (#4747).

Measured on Node 22 (nested bullet lists, 2 state levels per list level):

depth   600 ( 1201 levels)   cloneStateTree: ok           deepClone: ok
depth  1500 ( 3001 levels)   cloneStateTree: RangeError   deepClone: ok
depth  3000 ( 6001 levels)   cloneStateTree: RangeError   deepClone: ok
depth 10000 (20001 levels)   cloneStateTree: RangeError   deepClone: ok

The existing 600-level regression test in utils/__tests__/deepClone.spec.ts still passes, because it exercises deepClone directly — so the guard on getState() is silently gone with a green suite. The renderer's stack is smaller than Node's, so the real ceiling is lower than 1500.

2. meta is copied one level deep, but order-list meta really does hold an array

packages/muya/src/state/cloneState.ts:15

{ ...state.meta } is a shallow copy, and state/types.ts:78 declares:

sourceMarkers?: string[];  // Original item markers for no-edit source round-trips.

written at markdownToState.ts:139. So muya.getState()[0].meta.sourceMarkers is the live _state's array — deepClone isolated it, this doesn't. Any consumer mutating it corrupts the live document with no ot-json1 op behind it, which desyncs history/undo. stateToMarkdown.ts:598 already does listInfo.sourceMarkers?.shift(); it only escapes corruption today because line 226 re-clones via deepClone(state.meta) first.

Confirmed:

sourceMarkers aliased?   cloneStateTree: true     deepClone: false

Worth noting: cloneStateTree.spec.ts's second test is built on '1. first\n2. second\n' — which produces sourceMarkers — and is titled "keeps Muya.getState defensive", but it only mutates scalar meta fields, so it passes while the aliasing it looks like it covers is broken.

3. prevDoc doesn't get the same copy-on-write treatment, so every edit still deep-clones the whole document

packages/muya/src/state/index.ts:221 and :317

This PR's argument for making doc lazy is that ot-json1's apply is copy-on-write, so the post-apply root is already an immutable snapshot. That argument is correct — and it applies to prevDoc even more strongly, because the pre-apply root is abandoned by _apply and never touched again. prevDoc needs no getter, no memoization, and no clone at all.

I verified the whole chain against [email protected]:

apply is copy-on-write with structural sharing

input doc unchanged              : true
new root is a different object   : true
untouched subtree shared by ref  : true
edited subtree is a new object   : true
old root stays frozen across two subsequent edits : true

prevDoc's only consumer is read-only — it flows solely to History._record(op, prevDoc) → json1.type.invertWithDoc:

replace text   prevDoc unmutated: true
remove block   prevDoc unmutated: true
insert block   prevDoc unmutated: true
edit nested    prevDoc unmutated: true
remove nested  prevDoc unmutated: true

and it retains nothing: the subtree that invertWithDoc embeds into the inverse op (for removeOp) is a deep copy, not a live reference into prevDoc — so the undo stack never holds a pointer back into it.

Finally, _state in state/index.ts is only ever wholesale-reassigned (:65, :86, :90), never mutated in place — which is what makes the abandoned root permanently safe.

There's also a wasted clone: _flushOperationCache takes prevDoc before the if (op === null) return bail-out. op === null is a real case — the comment right above it says queued ops compose away (e.g. IME edits, #4806) — so every composed-away IME batch pays a full-document clone for an event that is never emitted. That's the highest-frequency path there is for CJK input.

Net effect on a large document, per edit:

full-document clones per edit
develop today 2
with this PR 1
with prevDoc fixed 0

Suggested path for the above

These two fixes resolve each other. Once prevDoc stops cloning, getState() is no longer on the per-keystroke path, and cloneStateTree's speed advantage stops buying anything — so the safe deepClone can just be used.

Benchmark, 4.37 MB JSON / 47,600 nodes, median of 13 runs (alternating call order, results fully consumed to defeat DCE):

cloneStateTree (recursive)    1.75 ms
cloneStateTree (iterative)    2.07 ms   (+18%)
deepClone                    12.88 ms   (7.4x)
structuredClone              23.99 ms   (13.7x)

deepClone is 7.4x slower in relative terms, but the absolute delta is ~11 ms — against this PR's own 90s → 25s headline, that's noise, and after fix 3 it isn't on a hot path at all.

So the simplest correct change is to delete cloneState.ts and keep deepClone. That drops blocking issues 1 and 2 plus should-fix 5 and test issue 12 below, purely by removing code.

If profiling later shows a schema-specific clone really is needed, it must (a) use an explicit stack and (b) deep-copy array-valued meta fields. I measured that variant at 2.07 ms — only 18% over the recursive version, and it passes every depth and aliasing check. Correctness doesn't have to be traded for speed here. In that case please also copy the 600-level regression case onto getState() itself, or #4747's guard stays unenforced.


Should fix

4. cloneStateTree crashes on malformed input and changes meta: undefined semantics

cloneState.ts:10, :23

'children' in state is a key-presence test, so { name: 'block-quote', children: undefined } reaches cloneStateTree(undefined) → TypeError: Cannot read properties of undefined (reading 'map'). That's reachable from externally supplied JSON: new Muya(el, { json }), muya.setContent(stateArray) and buildReplaceOp(stateArray) all flow in unvalidated.

Separately the leaf branch spreads state.meta with no truthiness guard (unlike the container branch at :12), so meta: undefined becomes meta: {} — which changes the JSON.stringify(prevState[i]) !== JSON.stringify(nextState[i]) comparison in buildReplaceOp and the literal values embedded in the emitted op.

Moot if deepClone is adopted.

5. The quadratic walkTokens driver is only removed from one of three call sites

getHighlightHtml.ts:50 and getClipboardHtml.ts:26 still register the same callback via m.use({ walkTokens }), which marked runs through its own accumulating driver inside parse(). getHighlightHtml feeds markdownToHtml.ts:196 (HTML/PDF/print export) and renderToStaticHTML.ts:52.

So the 2.1 MB document this PR measures at 25 s on open still pays the full O(tokens²) walk on export, print, and copy-as-HTML. Since the root cause is marked's concat accumulator, fixing it centrally rather than at one call site would close #4887 for those paths too — otherwise the issue is only half resolved from a user's point of view.

6. walkTokensLinear drops marked's childTokens branch

lexBlock.ts:39

marked 18's default branch is this.defaults.extensions?.childTokens?.[type] ? <walk each named child array> : token.tokens && <walk tokens>. The replacement only ever walks token.tokens. No muya extension declares childTokens today, so nothing breaks now — but the doc comment and the new spec both claim parity, and the first extension that registers one (marked's documented way to expose nested token arrays under a non-tokens key) would silently lose all muya augmentation on those children.

Minor, same function: :23 calls callback(token) where marked uses callback.call(this, token).

7. The cached collection still deep-clones the whole document for a read-only scan

inlineRenderer/index.ts:87

travel() only reads name, text and children — it never mutates. A read-only accessor on JSONState (e.g. peekState() returning this._state) scanned in place would remove the last remaining per-revision whole-document allocation this fix leaves behind.


Tests and docs

8. walkTokensLinear.spec.ts:30 — the test named "visits the same token set as Marked.walkTokens" never exercises walkTokensLinear. visitedTypes() walks with m.walkTokens, and the test body also walks lexBlock's output with m.walkTokens, so it compares two marked walks over two structurally equal trees. Deleting the entire body of walkTokensLinear's switch (making it visit top-level tokens only) leaves this test green. Only the second test carries real signal, and the parity claim is what fix 2 rests on.

9. cloneStateTree.spec.ts:33 — vi.spyOn(globalThis, 'structuredClone') is never restored (no mockRestore, no restoreAllMocks, and vite.config.ts sets no restoreMocks), so the second test constructs a real Muya and runs init() against the still-installed spy. expect(spy).not.toHaveBeenCalled() is also a brittle implementation-detail assertion.

10. jsonChangeDocCompat.spec.ts:37 and :64 — getContainer (muya.ts:1741) ends with originContainer.replaceWith(newContainer), so host is already detached and host.remove() is a no-op; both tests leak a live .mu-editor contenteditable into the shared happy-dom document. The sibling new spec gets this right (muya.domNode.remove() at cloneStateTree.spec.ts:72) — the two files disagree.

11. helpers.ts:258 — this one is worth separating from the rest. The added comment states that the final input event "can still be pending when a mode switch tears the editor down, permanently losing the last keystroke". That's a product bug, not a test bug: the guard in editor.vue's sourceCode watcher (editor.value.flush()) only drains ops already queued in JSONState._operationCache, and a keystroke whose DOM input event hasn't been dispatched has produced no op to flush. This PR ships only a test-side settle, with no product change and no issue reference — so a real user who types and immediately hits the source-mode shortcut still loses the character, and the e2e suite can no longer detect it. Could this be split out into its own issue and fixed on the product side?

12. helpers.ts:266 — requestAnimationFrame is suspended for occluded/minimized/background BrowserWindows, so on a runner where the window loses foreground the promise never settles and Playwright's action timeout fires. That turns one flaky spec into 12 failing ones (html-block-input, issue-2800, parity-source-undo-saved, parity-cursor-lang, editor-input, tabs). A page.waitForFunction on observable editor text has no such dependency.

13. editor-input.spec.ts:50-54 — duplicates the wait and nearly the exact comment (same typed-toke anecdote) that this PR just added inside typeIntoEditor, and the following expect.poll already retries. Two of the three guards are dead weight, and a future change to the helper would leave a stale contradictory comment here.

14. packages/muya/CLAUDE.md still states that InlineRenderer.collectReferenceDefinitions() "runs over the live block tree on every render pass" — after this PR it runs at most once per JSONState revision, so the governing doc for the package describes behavior the code no longer has. Separately, the comment added at editor.vue:1858 says reading doc "clones the current state", but the getter pins a snapshot taken at emit time — which is the point of the change and the opposite of "current".


To be clear about where this lands: the diagnosis and the measurements are solid, and I'd like this in. The blocking list is short and three of the four issues in it disappear by deleting a file rather than writing more code. Happy to talk through any of it if you disagree with the reasoning — particularly on 3, where I'd rather hear your take before you rework anything.

@Renakoni
Renakoni force-pushed the fix/large-document-open-freeze branch from 03d6ca7 to 21418d1 Compare September 19, 2026 05:03
@Renakoni

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. I rebased and pushed the revision in 21418d13; #4946 now builds on it and is updated through 37bd8816.

The main changes addressing your list:

  • Deleted cloneStateTree and retained develop's iterative deepClone, including array-valued metadata isolation. Incoming JSON and inserted OT values are also owned copies.
  • Reference-definition collection now scans complete state read-only and caches by revision, without cloning for the scan.
  • All three Marked entrypoints use the linear walker. The parity test now actually compares the replacement against Marked, including token identity/order, childTokens, callback this/results, and async highlighting.
  • Composed-away batches return before snapshot work; pending edits flush before undo/redo stack checks. Test cleanup and the cache/snapshot documentation are corrected.

On point 3, I agree about using the pre-apply root for read-only History. I kept one distinction for the public API: untouched subtrees are shared across OT roots, so exposing the raw root as public prevDoc lets a listener mutate live state. History now gets the root via a private WeakMap association; public doc and prevDoc remain memoized defensive snapshots. The internal recording path avoids the full snapshot clone, while tests cover delayed reads and mutation isolation. This is not a claim that desktop listeners or the entire edit path perform zero whole-document work.

I removed both the double-rAF settle and the duplicate wait. The new real typing-to-source-mode test passes without an added frame delay. That verifies the tested Windows/Electron path, not every possible un-dispatched-input race; the body now states that limit instead of treating a test wait as a product fix.

For #4942, local validation passed 1876 unit tests, 1347 specification tests, types/lint/circular checks, both builds, and 10 Electron tests; the final targeted rerun passed another 19 tests. The body identifies the tested revision and separates historical performance figures from current evidence.

I also re-reviewed #4946's consumers and caught a cancellation-versus-EOF bug: a callback replacing/destroying the document during frontier Enter could still cause an empty paragraph to be appended. The failing reproductions now pass, with 20 new cancellation/reentrancy cases and 131 final targeted tests. Its body separately reports the earlier full-run timeouts/rechecks and the final-patch checks. Giant single blocks remain atomic; I removed the claim that this is the final resolution of all large-document freezes.

Resolve the lexBlock conflict by keeping LinearMarked with texMathDollars, and update the two PR tests to the renamed option.
Renakoni added a commit to Renakoni/marktext that referenced this pull request Sep 19, 2026
Bring in develop and the conflict resolution from PR marktext#4942, preserving LinearMarked and the renamed texMathDollars option.
@mbrettschneider

Copy link
Copy Markdown

Tested on Linux (Ubuntu 24.04, GNOME 46, Wayland): this PR fixes slow tab switching to documents with large tables (#5829).

Switching to a 482-line document with four 115-row tables (≈12,000 DOM nodes), built from source with a fresh profile, three runs each:

Build Time
merge base 3e9e91c2 2.97–3.10 s
this PR, 523e128b 0.31–0.43 s

Both builds render the same number of DOM nodes. A ≈19,000-node real-world document switches in 0.56–0.59 s with this PR, against 8.2–8.5 s in v0.23.0. Details and the generator script for the test file are in #5829.

@Jocs

Jocs commented Oct 22, 2026

Copy link
Copy Markdown
Member

@Renakoni Updated this branch to Marked 18.1.1 and removed the local LinearMarked subclass. Upstream has shipped the main fix in markedjs/marked#4121: walkTokens now appends results in place instead of repeatedly copying the growing accumulator with concat. Maintaining our own traversal implementation no longer provides a performance advantage for the tested documents.

Same-machine comparison on Apple M4 Pro / Node 22.22.3, three warmups and nine rotating samples per implementation, median Markdown-to-HTML time:

Fixture Marked 18.1.0 Native 18.1.1 Our LinearMarked on 18.1.1
503 KB / 6,000 paragraphs 611.5 ms 41.6 ms 46.6 ms
335 KB / 6,000 table rows 206.3 ms 24.7 ms 25.6 ms

This benchmark includes lexing, a simple token callback, and HTML generation; it excludes Muya extensions, Prism and DOM mounting. All three implementations produced identical HTML for these fixtures.

The three production entrypoints (lexBlock, getHighlightHtml, and getClipBoardHtml) now use native Marked. Subclass-specific parity/depth tests were removed; the nested Muya token-augmentation regression remains. On the final code, 2,813 Muya unit tests, 1,347 specification tests, and 14 Electron regressions passed, along with desktop typecheck, scoped Muya lint, root lint (existing warnings only), and the desktop build.

One deliberate tradeoff: native Marked still walks recursively. In an isolated synthetic 10,000-level token-tree test it throws RangeError, whereas the removed subclass completed. This is a token-traversal boundary test, not an end-to-end Markdown measurement. We are accepting that upstream behavior to avoid carrying a separate walker.

Removal commit: 2c590da9. The dependency upgrade is in f342e27a.

@Jocs
Jocs merged commit 19cdbc1 into marktext:develop Oct 22, 2026
19 checks passed
@Jocs Jocs mentioned this pull request Oct 23, 2026
1 task done
Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 27, 2026
Brings in v0.22.0 and v0.23.0 and the start of 0.24.0: Electron 45,
GitHub Alerts, foldable headings, per-tab reading mode and --read-only,
the docked document outline, multiple folder roots, preview tabs, recent
files in quick open, Italian, and the large-document fixes of marktext#4942 and
marktext#5863.

Conflicts:

- muya state/inlineRenderer: marktext#4942 caches reference definitions per
  candidate state, which supersedes the fork's per-revision cache. Took
  upstream's; the fork's display math cache in mathPreview stays.
- editor.vue: kept the fork's deferred content snapshot (no getState()
  deep clone per keystroke), document virtualization and camera, on top
  of upstream's reading mode, shortcut resolvers and image drop. The
  json-change handler keeps upstream's loadingContent/readOnly guard,
  the source handoff and reload take upstream's loadingContent blocks,
  and scrollToHeader reveals folded headings before following the
  target. publishContentChange uses getSelectionState().
- Print/PDF: the fork's paged preview replaces MarkdownPrint and the
  printToPDF export path, so printService, its specs and the pdf branch
  of handleResponseForExport keep the fork's side. marktext#3323 moved image
  resolution into the engine; exportHtml drops its own image rewrite and
  keeps the fork's rendered-heading TOC.
- marktext#5802's assertExportDestination moves to main/filesystem so Save PDF in
  the preview refuses the source document too.
- syntheticHistory keeps the 53-bit cyrb53 hash over upstream's BigInt
  FNV-64 (~6 ms per key on a 500 KB note); the store keeps isSameList
  and drops deep-equal.
- Sidebar rows keep draggable alongside preview tabs; locales keep both
  printPreview and readingMode, and it.json gets the printPreview strings.

Merge adjustments:

- SET_READ_ONLY publishes the pending snapshot first: a read-only tab
  drops content changes, so an edit made within 150 ms of entering
  reading mode would otherwise be missing from the tab.
- marktext#5798 moved notices to the bottom-right corner, over the preview's
  Save PDF and Print buttons, and an export notice stays while hovered.
  The preview lifts notices clear of its actions while it is open.
- Specs: the docked outline is expanded by default and narrows the
  column, so the virtualization specs open it only when it is closed,
  measure the settled position and place their target inside the
  viewport. The camera specs press Control once before measuring,
  because since marktext#5878 the first key press re-renders the caret's heading
  with its marks shown.

Verified on Windows 11 (175%): typecheck, lint, the desktop unit suite
(1467) and the muya unit suite (3978) pass. In background windows the
e2e suite (514 passed, 45 failed) fails only where a build of
upstream/develop fails on this machine too (copy-anchor-link,
document-outline, image clipboard/relative path, 5394, 5685,
toc-active-heading, outline-layout, ...: 56 cases in 19 specs there),
plus media-viewer cases that flake on both when the 1 px image's resize
bar takes the click. print-preview, export-pdf, document-virtualization
and sidebar-file-drag pass, and editor-camera passes on screen.
reading-mode:54 needs the camera focus fix in the next commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants