You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Panic in vendored vt100 when resizing strands a wide character at the row boundary #1267
The vendored vt100 fork (vendor/vt100, v0.16.2) can panic when:
A two-column character is rendered near the right edge.
The terminal is narrowed so its continuation cell is truncated.
The remaining wide-character cell is overwritten.
The resulting panic is:
thread 'tokio-rt-worker' panicked at vendor/vt100/src/screen.rs:896:22:
called `Option::unwrap()` on a `None` value
This was observed in production with Construct v0.17.6. The omni-codex adapter crashed mid-session after repeated resizing and wide-character output.
Root cause
A two-column glyph occupies:
A cell for which is_wide() is true.
A continuation cell at col + 1 for which is_wide_continuation() is true.
When the terminal is narrowed, Grid::set_size calls Row::resize. Shrinking a row truncates its cell vector, but—unlike Row::truncate—does not clear a wide character when its continuation cell falls outside the new row width.
This leaves an is_wide() cell stranded in the final column.
When Screen::text later overwrites that cell, its wide-character cleanup path accesses pos.col + 1. That position is now outside the row, so drawing_cell_mut returns None and the unwrap() at screen.rs:896 panics.
Minimal reproduction
letmut parser = vt100::Parser::new(1,10,0);// Two-column glyph at zero-based columns 8 (wide) and 9 (continuation).
parser.process(b"\x1b[1;9H");
parser.process("世".as_bytes());// Narrow to 9 columns. The continuation at column 9 is truncated,// leaving the wide cell stranded in the new final column.
parser.screen_mut().set_size(1,9);// Overwriting the stranded wide cell panics at screen.rs:896.
parser.process(b"\x1b[1;9HX");
Expected behavior
Resizing and subsequently overwriting the cell should not panic. If shrinking removes a wide character's continuation cell, the remaining half should be cleared.
Actual behavior
The overwrite panics at vendor/vt100/src/screen.rs:896 because the expected continuation cell no longer exists.
Suggested fix
When Row::resize shrinks a row, clear any wide-character cell stranded in the new final column. This should mirror the boundary cleanup already performed by Row::truncate.
A regression test covering the sequence above would also help prevent recurrence.
Activity