Repository navigation
fix: open documents with many list items without rescanning the file - #676
Merged
Merged
Conversation
4 tasks done
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
The list form pass reads every list item's indentation from the start of the item's line back to its marker. It found that line start with
lastIndexOf("\n")andlastIndexOf("\r"). When the file had no character of one of those kinds, that search ran back to the start of the file. Files without carriage returns hit this for every item, and so did CR-only files for\n. Opening therefore cost list items times file size: #638 measured 0.9 s of opening a 1 MB document and 22 s, 45%, of a 5 MB one.readListItemIndentnow steps back from the marker to the nearest\nor\r, so finding the line start costs no more than that line. The slice it returns is unchanged.Related Issue
Closes #674
Verification
markdownCompatibilitycase opens and saves one document written with LF, CRLF, and CR line endings. The document has an item at offset 0, tab-indented nested items, an item one column off its sibling, and nested lists in a quote. It passes before and after the change, confirming that list form round trips are unchanged for all three line endings.pnpm check:frontendpassed.Not verified: opening the 5 MB document from #674 in a release build. In the current build, the block gutters' cost (#670) hides this pass.