action: Don't re-wrap the rest of the buffer on PageDown with softwrap - #4245
Open
4RH1T3CT0R7 wants to merge 1 commit into
Open
4RH1T3CT0R7 wants to merge 1 commit into
4RH1T3CT0R7 wants to merge 1 commit into
Conversation
ScrollAdjust(), ScrollReachedEnd(), GotoLoc() and initialRelocate() use Diff() only to compare a distance with the view height. With softwrap on, Diff() counts the rows of every line in between, so PageDown near the top of a large file wraps everything down to the end of the buffer, and GotoLoc() wraps everything between the old and the new location. Compare against Scroll() by at most a view height instead, the same way Relocate() and CursorToViewBottom() already do. Scroll() stops after that many rows, so the cost no longer depends on the buffer size, and the resulting view is the same. Fixes micro-editor#3964
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.
with softwrap on,
ScrollAdjust(),ScrollReachedEnd(),GotoLoc()andinitialRelocate()useDiff()to compare a distance with the view height, andDiff()wraps every line in between. so paging down near the top of a big file re-wraps the rest of the buffer, andGotoLoc()re-wraps everything between the old and new cursorthey now compare against
Scroll()by at most a view height, likeRelocate()does. on the file from the issue PgDn goes from about 600 ms to under 2 ms per press and a jump from line 0 to 34000 from over 800 ms to about 1 ms. the new checks agree with the old ones for every view position, the added test in cmd/micro passes on bothFixes #3964