Skip to content

Fixed(terminal-emulator): Do not scroll the region on RI above the top margin - #5353

Open
matthematics1137 wants to merge 1 commit into
termux:masterfrom
matthematics1137:fix-ri-above-scroll-region
Open

matthematics1137 wants to merge 1 commit into
termux:masterfrom
matthematics1137:fix-ri-above-scroll-region

Conversation

@matthematics1137

Copy link
Copy Markdown

Reverse Index (ESC M) scrolls the scroll region down whenever the cursor is
at or above the top margin. When the top margin is below the first line and the
cursor is above it, the region's content moves down a line and its last line is
lost, while the cursor stays where it was.

To reproduce:

printf '\033[2J\033[H111\n222\n333\n444\n555\033[3;5r\033[2;1H\033MX\033[r\033[8;1H'

xterm, tmux and xterm.js print X over the first 1 and leave lines 3 to 5
alone. Termux prints X on line 2, and lines 3 to 5 scroll down: line 3 is
blank and 555 is gone.

xterm's RevIndex() says it directly: "reverse indexing when above scrolling
region is cursor up". This change scrolls only when the cursor is on the top
margin. Above it, RI moves the cursor up and stops at the first line.

Test: ScrollRegionTest.testRiAboveTopMargin.

…p margin

Reverse Index (`ESC M`) scrolled the scroll region down whenever the cursor
was at or above the top margin. With a top margin below the first line and
the cursor above it, the region's content moved down a line (and its last
line was lost) while the cursor stayed where it was.

Only scroll when the cursor is on the top margin. Above it, RI is a plain
cursor up that stops at the first line, as in xterm, tmux and xterm.js.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant