Skip to content

perf(editor): stop blocking full-doc parse on note open#189

Merged
thetechjon merged 1 commit into
devfrom
fix/heading-fold-blocking-parse
Jun 15, 2026
Merged

perf(editor): stop blocking full-doc parse on note open#189
thetechjon merged 1 commit into
devfrom
fix/heading-fold-blocking-parse

Conversation

@thetechjon

Copy link
Copy Markdown
Collaborator

Root cause

Every note switch took ~1s. The editor is keyed per-note, so it fully remounts on each switch. src/components/editor/foldableHeadings.ts resolved the syntax tree with ensureSyntaxTree(state, state.doc.length, 5000), which forces a synchronous, blocking, full-document lezer parse (up to a 5s budget) at mount time — stalling the UI on each note open.

Fix

One-line change in resolveTree: use the non-blocking syntaxTree(state) instead, matching every other live-preview extension in the codebase. The fold gutter only ever queries visible lines, so the forced full-doc parse was unnecessary. The now-unused ensureSyntaxTree import was removed (it had no other reference in the file).

Checks

  • npm run lint — pass
  • npm run typecheck — pass
  • npm test -- --ci — 3017 passed / 17 skipped, all 9 foldableHeadings tests green (they run on headless EditorState/EditorView and resolve fine via syntaxTree)

Build and Playwright e2e skipped.

Verify

The perf win should be confirmed by switching between notes on the Vercel preview — note open should no longer stall.

🤖 Generated with Claude Code

The heading-fold foldService forced ensureSyntaxTree(doc.length, 5000ms)
on every per-note editor remount, causing a ~1s stall on each note
switch. Use the non-blocking syntaxTree(state) like the other live-
preview extensions; the fold gutter only needs visible lines.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thetechjon thetechjon merged commit e77f6d5 into dev Jun 15, 2026
3 checks passed
@thetechjon thetechjon deleted the fix/heading-fold-blocking-parse branch June 15, 2026 05:23
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.

1 participant