Repository navigation
fix: renumber only the code blocks an edit changes - #682
Merged
Merged
Conversation
3 tasks
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
While code line numbers were shown, every document change rebuilt the line-number decorations of every code block in one new
DecorationSet, which costs top-level blocks times decorations. Typing anywhere in a document with much code slowed with the square of its code, as highlighting did before #678.codeBlockDecorationsutility, and both plugins use it: the set is built once, then each transaction maps it and decorates again only the code blocks in its changed ranges, plus every code block inside a node whose own boundary it changed. Highlighting behaves as before.docs/architecture.mddescribes the line numbers alongside the incremental highlighting, and the existingCHANGELOG.mdentry for faster typing in code-heavy documents now covers line numbers.Related Issue
Closes #679
Verification
pnpm check:frontendpassed.Manually verified in a happy-dom test mount on Windows 11, with a temporary probe that was not committed:
The fixture was about 1 MB of fenced code: roughly 1,030 30-line excerpts of the repository's TypeScript, Rust, and CSS, each after a one-sentence paragraph. Each keystroke's transaction was applied to the editor state seven times at the end of the middle paragraph and seven times inside the middle code block.
mainat fa9e842Not verified: keystroke times in a release build.