thing-tui: clamp a cursor move below crossterm's overflow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-29 01:41:53 +01:00
commit 2ca326293c

View file

@ -94,8 +94,9 @@ impl<W: Write> Drop for Terminal<W> {
}
}
/// crossterm adds one to a coordinate to make it 1-based, so the last it can write is `u16::MAX - 1`.
fn clamp(n: usize) -> u16 {
u16::try_from(n).unwrap_or(u16::MAX)
u16::try_from(n).unwrap_or(u16::MAX).min(u16::MAX - 1)
}
/// Paint already composited alpha; `None` is the terminal's own colour.