Keep a line's double-size attribute when only its text is erased - #153
Merged
Conversation
EraseLineCells reset LineAttribute to Normal on any whole-line erase. That reset exists for ED -- vttest erases the display between screens, and an attribute carried across it doubled whatever the next screen wrote -- but it also caught EL and ECH, which erase a line without ending it. The attribute is a property of the LINE, not of the text on it, and DEC keeps it across both. vttest's double-size test (menu 4) is built to catch exactly this. Row 14 is the only line on that screen carrying an EL, and it arrives after the DECDHL and before the text: ESC[14;2H ESC#6 ESC#5 ESC#4 ESC#3 ESC[2K, then the line. Dropping the attribute there drew row 14 at normal size and left the double-height bottom half on row 15 with no top half above it. Make the reset opt-in with resetLineAttribute, passed only from the three ED loops and from EraseWholeScreen (DECCOLM's clear). EL 0/1/2 and ECH now leave the attribute standing. Tests cover both halves of the pair. The ED reset had no test of its own, which is what let a narrowing like this look free. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Boundary forms of ED 0 and ED 1 no longer reset the current row’s line attribute.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Preserves double-size line attributes for EL/ECH while retaining resets for display erasure.
Changes:
- Makes line-attribute resets opt-in for erase operations.
- Adds regression tests for EL, ECH, and ED behavior.
File summaries
| File | Description |
|---|---|
InputHandler.Protection.cs |
Adds conditional line-attribute resetting. |
InputHandler.Csi.cs |
Enables resetting in ED loops. |
VtTestBehaviourTests.cs |
Tests line and display erasure behavior. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+389
to
+390
| EraseLineCells(_buffer.Lines[_buffer.YBase + i], 0, _terminal.Cols, selective, | ||
| resetLineAttribute: true); |
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.
The bug
EraseLineCellsresetLineAttributetoNormalon any whole-line erase. That reset exists for ED -- vttest erases the display between screens, and an attribute carried across it doubled whatever the next screen wrote -- but it also caught EL and ECH, which erase a line without ending it. The attribute is a property of the LINE, not of the text sitting on it, and DEC keeps it across both.vttest's double-size test (menu 4) is built to catch exactly this. Row 14 is the only line on that screen carrying an EL, and it arrives after the DECDHL and before the text:
vttest wiggles the attribute through all four values, lands on
ESC#3(double-height top), then erases the line before writing to it. Dropping the attribute there drew row 14 at normal size and left row 15's double-height bottom half sheared, with no top half above it.The fix
Make the reset opt-in via a
resetLineAttributeparameter, passed only from the three ED loops inEraseInDisplayand fromEraseWholeScreen(DECCOLM's clear). EL 0/1/2 and ECH now leave the attribute standing. ECH is included because at column 0 with a count covering the line it satisfied the same whole-line test.Tests
A theory over
EL 2 / EL 0 / EL 1 / ECHasserting the attribute survives, plus its complement asserting ED 2 still clears it.The ED reset had no test of its own -- the only existing coverage was
A_full_erase_keeps_the_width_of_a_line_whose_text_survived, which pins the ISO-guarded case. A narrowing like this one is exactly the change that overshoots silently, so both halves of the pair are now pinned.Full suite: 2214 passed, 0 failed.
Verifying
Run vttest and pick menu item 4. Both double-height pairs should render as continuous large lines. Before this change the second pair rendered as a normal-size line above an orphaned, sheared bottom half.
🤖 Generated with Claude Code