Fix stale rows when scrolling a restricted region (CoreGraphics renderer)#582
Open
tavvet wants to merge 1 commit into
Open
Fix stale rows when scrolling a restricted region (CoreGraphics renderer)#582tavvet wants to merge 1 commit into
tavvet wants to merge 1 commit into
Conversation
Full-screen apps with a fixed header/footer use a restricted scroll region. The scroll primitives flagged only [scrollTop, scrollBottom] for refresh, so rows outside the region — and the last row, which needs rowEnd == rows-1 to hit updateDisplay's bottom-edge "remaining bits" branch — kept stale pixels on the CoreGraphics renderer: right-side tails on long lines and a ghost line at the bottom while paging in nano. Add refreshScrolledRegion(top:bottom:): repaint the whole viewport for a restricted region or the alternate buffer; a full-screen scrollback scroll keeps the cheap region-only path. Used by scroll(), reverseIndex(), cmdScrollUp() and cmdScrollDown().
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.
Problem
Full-screen ncurses apps that keep a fixed header and/or footer —
nano, andvim/less/htopin some layouts — set a restricted scroll region (DECSTBM, e.g. rows[1, 43]of a 46-row screen). While scrolling such a region, rows outside the region keep stale pixels, and a "ghost" line lingers on the very last row while paging.Reproducible on the CoreGraphics renderer (Metal disabled): open
nanoon a file with lines wider than the window and hold PageDown/PageUp — stale rows and a bottom ghost appear.Root cause
scroll(),reverseIndex(),cmdScrollUp()andcmdScrollDown()flag only[scrollTop, scrollBottom]for refresh viaupdateRange. For a restricted region (scrollTop != 0orscrollBottom != rows-1) or the alternate buffer:scroll()makes viayBase) are never repainted, andgetUpdateRange()returnsrowEnd == rows-1, which triggersupdateDisplay's bottom-edge "remaining bits" branch — a restricted region never produces thatrowEnd.So those rows keep stale backing-store pixels on the CG path.
Fix
Add
refreshScrolledRegion(top:bottom:): when the region is restricted or we're on the alternate buffer, repaint the whole viewport (endLine == rows-1); a real full-screen scrollback scroll keeps the cheap region-only path (its scroll blit handles the bottom edge). Call it from the four scroll primitives. The whole-viewport repaint is safe on the Metal path too (it just widens the dirty range).Testing
Logged
updateDisplay's(rowStart, rowEnd): a restricted-region scroll now producesrowEnd == rows-1(bottom-edge branch) instead ofrowEnd == scrollBottom. Verified visually innano/vim/less— no stale rows or bottom ghost while paging. The package builds cleanly.