Skip to content

terminal: mark the previous row dirty when clearing its spacer head - #14054

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
fornwall:split-cell
Aug 28, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
fornwall:split-cell

Conversation

@fornwall

@fornwall fornwall commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Erasing a wrapped wide character at the start of a row (ECH or DCH) also clears the spacer head it left at the end of the previous row, but that row was never marked dirty. With both rows visible, an incremental render kept the stale spacer head on screen until something unrelated redrew that row.

The clearing happens in the row-start branch of splitCellBoundary. clearCells doesn't do dirty tracking, and both callers only mark the cursor row, so mark the previous row at the point it's mutated.

The added dirty assertions fail without the fix.

AI Disclaimer

Claude did the heavy lifting - identifying the root cause, generating code and description. I reviewed and iterated on it to move around and tweak tests, comments and reduce verboseness. Verified the end user visible behaviour improvement with a script that coloured the wide character, which made the stale rendering visible until a switch to the alt screen and back cleared it it.

Erasing a wrapped wide character at the start of a row (ECH or DCH)
also clears the spacer head it left at the end of the previous row,
but that row was never marked dirty. With both rows visible, an
incremental render kept the stale spacer head on screen until
something unrelated redrew that row.

The clearing happens in the row-start branch of splitCellBoundary.
clearCells doesn't do dirty tracking, and both callers only mark
the cursor row, so mark the previous row at the point it's mutated.

The added dirty assertions fail without the fix.
@fornwall
fornwall requested a review from a team as a code owner August 28, 2026 00:11
@ghostty-bot ghostty-bot Bot added the vt Control sequence related label Aug 28, 2026
@mitchellh

Copy link
Copy Markdown
Contributor

Spacer heads don’t participate or affect rendering so they don’t need to participate in dirty tracking. Or am I wrong

@fornwall

Copy link
Copy Markdown
Contributor Author

Spacer heads carry style, right? Standing at the end of line, print (with a background color) a wide character so it wraps -> the last column (carrying the spacer head) is rendered with the background color.

And if the wrapped wide char is erased that clears the last column to the erase background, meaning that the previous row needs re-rendering.

@fornwall

fornwall commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Standing at the end of line, print (with a background color) a wide character so it wraps -> the last column (carrying the spacer head) is rendered with the background color.

It's not obvious if this is the correct behaviour - it means that printing a single background colored wide character at end of line colors three cells: the spacer head at end of the previous line, and the two wide char cells at the start of the next line.

Screenshot 2026-08-28 at 02 45 00

But a motivation for why this, the current behaviour (minus the missing dirty tracking), is correct/desired: Otherwise a long stretch of uniformly background colored content would have a hole in the last column here.

@mitchellh
mitchellh merged commit 76e568b into ghostty-org:main Aug 28, 2026
101 checks passed
@fornwall
fornwall deleted the split-cell branch September 2, 2026 23:23
@mitchellh mitchellh added this to the 1.4.0 milestone Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vt Control sequence related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants