fix: background-colour erase (bce) for ESC[K past written text - #235
Open
smohekey wants to merge 1 commit into
Open
fix: background-colour erase (bce) for ESC[K past written text#235smohekey wants to merge 1 commit into
smohekey wants to merge 1 commit into
Conversation
A BufferLine is only painted up to its `_length`, and `eraseRange` clamped the erase to `_length` — so an app that sets a background then emits `ESC[K` (erase to end of line) to fill the rest of a row got a row coloured only under the text it had written, not the full width. This is background-colour erase (bce), which real terminals and xterm.js implement. When the pen carries an explicit background, grow the line to the erase boundary so the erased cells exist and render with that background. Default-background erases stay trimmed, preserving the previous behaviour (and keeping trailing cells out of selection/copy). Reproduces with e.g. `ESC[42mAB ESC[K` — cells past "AB" now carry the green background. Full-screen TUIs that draw diffs this way (e.g. the Codex CLI) were rendering patchy backgrounds without it.
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
A
BufferLineis only painted up to its_length, anderaseRangeclamps the erase to_length. So when an application sets a background colour and then emitsESC[K(erase to end of line) to fill the rest of a row — the standard, efficient way to draw a full-width coloured row — only the cells under the already-written text get the background; the rest of the row stays the default colour.This is background-colour erase (bce), which xterm, VTE, and xterm.js all implement. Full-screen TUIs that draw diffs or status bars this way (e.g. the Codex CLI) render patchy backgrounds in xterm.dart.
Reproduce
Fix
When the pen carries an explicit background, grow the line to the erase boundary so the erased cells exist and render with that background. Default-background erases stay trimmed, preserving the previous behaviour (and keeping trailing cells out of selection/copy).
Test
Adds
test/src/core/buffer/bce_test.dartcovering both the coloured-erase fill and the default-erase-stays-trimmed case.