Repository navigation
fix: #5860 reduce layout work when switching large files - #5863
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5860.
Summary
Switching back to a large Markdown tab rebuilds the editor and then performs avoidable work on the connected document: assigning
contentEditableeven when its value is unchanged, rewriting the same attribute on content nodes, and hiding the editor before restoring its scroll position. The visibility change forces additional layout work for the entire document.Performance evidence
Measured in the built Electron app on macOS using the author's original 265,184-byte attachment from #5860, alternating with a roughly 20 KB document. Timing runs from tab activation through two animation frames, with CPU profiling enabled for both versions.
This reduces the measured tab-switch latency by about 29%. The baseline profile identified
_refreshReadingPresentationand the scroll/visibility restoration layout work as major costs. The original attachment and profiling artifacts are kept outside the checkout.Type of change
Test plan
pnpm run build:unpackpnpm run lint(no errors; existing warnings)pnpm run typecheckpnpm -C packages/muya lintpnpm -C packages/muya lint:typespnpm -C packages/muya test— 2,871 tests passedpnpm test:unit— 1,209 tests passedlarge-file-tabs.spec.ts,cli-read-only.spec.ts, andexternal-reload-undo.spec.ts— 7 tests passedNotes for reviewers
The reported Windows 11 / MarkText 0.23.0 freeze of 6–7 seconds was not reproduced on this macOS / current-development-branch environment. This PR addresses measured overhead in the current code; it does not establish that the original Windows scenario is fully resolved. This PR closes #5860 on merge. The issue comment records these measurements and the recently merged performance improvements (#4942 and #5856), and asks the reporter to retest a build containing the changes and reopen the issue if the Windows freeze persists.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.