#240

fix(core): reflow soft-wrapped lines on resize in the built-in core

OpenRaillywants to merge intofrom

Problem

Resizing to fewer columns in the built-in core cut each row at the new width and discarded the rest, so narrowing a pane or rotating a phone lost output. Growing again could not bring it back. Fixes #237, reported by @johnhenry.

Changes

  • Rows record whether they continue onto the next row through autowrap. The flag moves with scrolls, clears on erase, and is kept in scrollback.
  • A width change on the primary screen joins rows into logical lines, rewraps history and visible rows at the new width, and moves rows between scrollback and the grid as their height changes. Wide cells stay paired and the cursor stays at its position in its line.
  • The alternate screen keeps truncating, as xterm and Ghostty do, and a resize that cannot allocate its work buffers falls back to the previous behavior.

Merge order

Merge this before #242. #242 scrolls by moving an offset instead of copying rows, so the soft-wrap flags added here must move with that offset. #242 picks up the fix and a cross test after this lands; nothing changes in this PR.

Visual proof

The same output, narrowed from 760px to 300px and widened back, against main and this branch.

Before: the end of each long line is gone at 300px and stays gone at 760px.

https://github.com/user-attachments/assets/52a377fe-6eb9-4272-b0aa-bb030de67de6

After: lines rewrap when narrow and rejoin when wide.

https://github.com/user-attachments/assets/3af4c1a8-4754-45f3-84e3-9c63f503392e