fix: scroll a partial DECSTBM region within itself, not below it - #236
Open
smohekey wants to merge 1 commit into
Open
fix: scroll a partial DECSTBM region within itself, not below it#236smohekey wants to merge 1 commit into
smohekey wants to merge 1 commit into
Conversation
When the cursor is on the bottom margin and a line feed occurs, `index()` grew the scrollback (inserting a line just below the last visible row) whenever `marginTop == 0`. That's only correct for a *full-height* scroll — a region whose bottom is the last row of the screen. For a *partial* region (top margin 0 but bottom margin above the last row) it inserted a line *below* the region, shoving everything underneath out of place instead of scrolling the region's own rows. Gate the scrollback-growth path on the region also reaching the last row (`marginBottom == viewHeight - 1`); otherwise scroll within the region. Applications that redraw part of an inline UI with partial scroll regions (e.g. ratatui's inline viewport, used by the Codex CLI) were getting scrambled output.
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
When the cursor is on the bottom margin and a line feed occurs,
index()grows the scrollback (inserts a line just below the last visible row) whenevermarginTop == 0. That's only correct for a full-height scroll — a region whose bottom is the last row of the screen.For a partial region (top margin 0, but bottom margin above the last row — e.g.
ESC[1;9ron a 24-row screen), it inserts a line below the region, shoving everything underneath out of place instead of scrolling the region's own rows. Applications that redraw part of an inline UI with partial scroll regions — ratatui's inline viewport, used by the Codex CLI — get scrambled output.Reproduce
Fix
Gate the scrollback-growth path on the region also reaching the last row (
marginBottom == viewHeight - 1); otherwise scroll within the region (scrollUp).Test
Adds
test/src/core/buffer/scroll_region_test.dartasserting the rows below a scrolled partial region are undisturbed and the region itself scrolls correctly.