Skip to content

Keep a line's double-size attribute when only its text is erased - #153

Merged
tomlm merged 1 commit into
tomlm:mainfrom
JohnCampionJr:fix/el-keeps-line-attribute
Sep 2, 2026
Merged

Keep a line's double-size attribute when only its text is erased#153
tomlm merged 1 commit into
tomlm:mainfrom
JohnCampionJr:fix/el-keeps-line-attribute

Conversation

@JohnCampionJr

Copy link
Copy Markdown
Collaborator

The bug

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 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:

ESC[14;2H  ESC#6 ESC#5 ESC#4 ESC#3  ESC[2K  This is another such line
ESC[15;2H  ESC#6 ESC#5 ESC#3 ESC#4          This is another such line

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 resetLineAttribute parameter, passed only from the three ED loops in EraseInDisplay and from EraseWholeScreen (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 / ECH asserting 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

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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);
@tomlm
tomlm merged commit b29aa81 into tomlm:main Sep 2, 2026
5 checks passed
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.

3 participants