Repository navigation
Open
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
Area
Source or split view
PreviewMD version
1.7 (11)
System
macOS 27 beta 2
Reproduction steps
- Open the attached synthetic document (large-sample.md, ~127 kB: chapters,
tables, lists, code blocks, inline formatting; no diagrams or math). - Edit it in the rendered (Preview) view and press a character key several
times in a row. - Switch to the source (Markdown) view and repeat.
Expected behavior
While editing (both views), adding text is fast and responsive.
Actual behavior
In both the rendered view and the source view, characters appear with a large,
clearly noticeable delay after the keys are pressed. Typing does not keep up
with input in either mode.
Minimal document, screenshots, or logs
No profiling data — this is a report of observed behavior only. The attached
document is synthetic, generated from random syllables, and contains no real
content.
Observation and suggestion: the delay appears to scale with the size of the
document rather than with the size of the edit, and it affects both editing
modes, which would be consistent with the whole document being rebuilt on every
keystroke instead of just the part that changed.
Reading the source, there is a whole-document code path on each side:
- Rendered view: emitChange() in editor.js calls serializeDocument(), which
walks the entire article DOM and reassembles the full Markdown string, then
calls refreshSplitSourcePositions(), which serializes every top-level block a
second time and locates each one inside the full string — and that runs
whether or not split view is in use.
- Source view: MarkdownSourceEditor.highlight() reapplies its regular
expressions across the whole text on every change. Because WorkspaceView keeps
both editors alive and only changes their frames, an edit made in the source
pane also drives a full previewmdRender() of the entire document in the web
view, even when the preview is not visible.
If that is the cause, caching and incremental work would help more than
micro-optimisation: keep the serialized form of each top-level block and
re-serialize only the block containing the edit; restrict highlighting to the
affected range; and skip work for a pane that is currently hidden. The
block-level source ranges needed for the first part already exist as
data-previewmd-source-start / data-previewmd-source-end.
Note on the environment: macOS 27 is a beta release, so I cannot rule out that
the OS contributes.
Before submitting
- I searched existing issues for this behavior.
- I removed private and sensitive information from attachments and logs.
- This is not a security vulnerability; security reports follow SECURITY.md.
Reacted by Adam Jesionkiewicz
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Activity
ashtree74 commentedon Aug 18, 2026
Thank you. I'll take care of that in the next version.
ashtree74 commentedon Oct 6, 2026
PreviewMD 1.8 (12) now includes the large-document editing changes from #29, merged into
main.Source highlighting updates affected logical lines; rich editing caches unchanged blocks and avoids unnecessary source-position work outside split view; hidden previews defer rebuilding; disk checks and outline work are moved away from the main editing path.
Using the attached synthetic sample, the local source-highlighting median improved from 9.32 ms to 2.17 ms, and warm rich serialization from 6–8 ms to 0–1 ms. These are component measurements, not complete keystroke-to-screen latency; details and limitations are in the regression audit.
Could you retest the same attachment in Preview, Markdown and split view with the signed and notarized 1.8 (12) DMG? If noticeable lag remains, please note the view, macOS version and Mac model.
Keeping this bug open for confirmation of the complete workflow. Thank you for the useful sample and diagnosis.