Skip to content

fix(addon-serialize): clamp serialized rows to terminal.cols - #6235

Open
Tyler-V wants to merge 1 commit into
xtermjs:masterfrom
Tyler-V:fix/addon-serialize-clamp-to-cols
Open

Tyler-V wants to merge 1 commit into
xtermjs:masterfrom
Tyler-V:fix/addon-serialize-clamp-to-cols

Conversation

@Tyler-V

@Tyler-V Tyler-V commented Oct 14, 2026

Copy link
Copy Markdown

Fixes #6229

Summary

  • Clamp the row walk in BaseSerializeHandler.serialize to terminal.cols
  • Clamp StringSerializeHandler._rowEnd to terminal.cols as well: its reads of the row's last two cells and its forced wrap cleanup moves
  • Move _terminal into BaseSerializeHandler so the shared row walk can read cols

Problem

A buffer line can be longer than the grid. After a column shrink on the alt buffer, every line keeps its old length (#6228). The serializer walked each row to line.length, so a frame carried cells the grid no longer has and a replay at the current width garbled rows. _rowEnd also read the row's last cells and built the moves that erase its - wrap filler from line.length, so the filler stayed on screen.

Fix

Each row stops at Math.min(line.length, terminal.cols), and _rowEnd uses the same length. serializeAsHTML shares the row walk, so its rows stop at cols too.

Buffer.resize is untouched. #6228 tracks that gap. Clamping in the addon keeps frames on the grid for any path that leaves a line longer than cols.

Test plan

The tests reach a long line through the alt buffer gap in #6228. Once that is fixed they still pass, but they no longer exercise the clamp.

🤖 Generated with Claude Code

A buffer line can be longer than the grid. After a column shrink on the
alt buffer, every line keeps its old length (xtermjs#6228). The row walk went
to line.length, so the frame carried cells the grid no longer has. The
forced wrap separator also read the row's last cells and built its
cleanup moves from line.length, so a replay left '-' filler on screen.

Clamp the row walk and the separator to terminal.cols. serializeAsHTML
shares the row walk, so its rows stop at cols too.

Fixes xtermjs#6229

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

SerializeAddon serializes cells past terminal.cols when a line is longer than the grid

1 participant