Skip to content

Respect erase attributes (back-color-erase) for scrollDown blank lines - #6035

Open
spokodev wants to merge 1 commit into
xtermjs:masterfrom
spokodev:fix/scrolldown-erase-attributes
Open

Respect erase attributes (back-color-erase) for scrollDown blank lines#6035
spokodev wants to merge 1 commit into
xtermjs:masterfrom
spokodev:fix/scrolldown-erase-attributes

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026

Copy link
Copy Markdown

scrollDown (SD, CSI Ps T) does not honor back-color-erase: the blank line it inserts at the top of the scroll region is filled with DEFAULT_ATTR_DATA instead of the current SGR background.

Every other place that introduces blank cells (ED, EL, ECH, alt-buffer clear, insertLines, deleteLines, and notably its sibling scrollUp) uses this._eraseAttrData(), which folds the active background into the erase attributes. Only scrollDown uses the default, so after an application sets a background (for example CSI 41m) and scrolls the region down, the new line shows the terminal default background instead of the active one, leaving a wrong cell-attribute state that is visible in TUIs and shells.

Fix

Use this._eraseAttrData() for the inserted line, matching scrollUp (InputHandler.ts) and the other blank-cell paths. DEFAULT_ATTR_DATA is still used elsewhere, so there is no orphaned import.

Testing

Added a test to the scroll margins block of InputHandler.test.ts: set a red background, define a scroll region, scroll down, and assert the inserted blank line carries that background. It fails on the current code (background color comes back as the default) and passes with the fix. The full InputHandler suite stays green (193 passing).

scrollDown filled the blank line it inserts at the top of the scroll
region with DEFAULT_ATTR_DATA, while scrollUp, insertLines, deleteLines
and the erase operations all use the current erase attributes. As a
result, scrolling down after setting a background color (back-color
erase) produced a line with the default background instead of the active
one. Use _eraseAttrData() to match the sibling operations.
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