perf(editor): stop blocking full-doc parse on note open#189
Merged
Conversation
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>
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.
Root cause
Every note switch took ~1s. The editor is keyed per-note, so it fully remounts on each switch.
src/components/editor/foldableHeadings.tsresolved the syntax tree withensureSyntaxTree(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-blockingsyntaxTree(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-unusedensureSyntaxTreeimport was removed (it had no other reference in the file).Checks
npm run lint— passnpm run typecheck— passnpm test -- --ci— 3017 passed / 17 skipped, all 9foldableHeadingstests green (they run on headless EditorState/EditorView and resolve fine viasyntaxTree)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