Repository navigation
fix: stop serializing the whole document after every edit - #681
Merged
Merged
Conversation
…ation # Conflicts: # CHANGELOG.md # src/features/editor/utils/createMilkdownEditor.ts
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.
Summary
After each edit, once typing paused for 200 ms, Milkdown's listener plugin serialized the whole document so the session held a current copy of its Markdown, and it serialized once more when the editor was created. That blocked the main thread for about a third of a second in a 200 KB document of tables and about a second at 500 KB (#672).
The listener is removed. The session's
contentis now the Markdown a document was opened, created, or last saved with, and each reader that needs the current text gets it from the editor:The bridge's
getMarkdownreturnsnullinstead of throwing while the editor is still being created, so these readers fall back to the session's text, which no edit can have changed yet.Related Issue
Closes #672
Verification
openSession: an edited document whose session text still matches the file reloads when reopened after its edits are discarded.document-screen: edits fire the content signal without changing the session's text; when the editor unmounts, the edited Markdown moves to the session and the next editor mounts with it.documentWorkflows: Save writes the handed-over text once no editor holds the document, and a clean or replaced document's editor is not read.folderSearchWorkflows: the open document's results follow an edit once it settles.pnpm check:frontendpassed after mergingmain.Manually verified in a Windows 11 release build, before merging #675–#678 from
main:mainat 7cea7b9 recorded a 636–1179 ms timer frame 230–290 ms after every keystroke at 205 KB.Not verified: the release-build timings after merging #675–#678.