Skip to content

action: Don't re-wrap the rest of the buffer on PageDown with softwrap - #4245

Open
4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/softwrap-pagedown
Open

4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/softwrap-pagedown

Conversation

@4RH1T3CT0R7

Copy link
Copy Markdown
Contributor

with softwrap on, ScrollAdjust(), ScrollReachedEnd(), GotoLoc() and initialRelocate() use Diff() to compare a distance with the view height, and Diff() wraps every line in between. so paging down near the top of a big file re-wraps the rest of the buffer, and GotoLoc() re-wraps everything between the old and new cursor

they now compare against Scroll() by at most a view height, like Relocate() 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 both

Fixes #3964

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PgUp/PgDown scrolling slow in large files with softwrap enabled

1 participant