thing-tui: a draw of no ops writes nothing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-29 01:52:25 +01:00
commit f1c5978d77
2 changed files with 6 additions and 3 deletions

View file

@ -60,8 +60,11 @@ impl<W: Write> Terminal<W> {
Ok(terminal)
}
/// Serialize `ops` as one synchronized update and flush once.
/// Serialize `ops` as one synchronized update and flush once. No ops write nothing.
pub fn draw(&mut self, ops: &[Op]) -> io::Result<()> {
if ops.is_empty() {
return Ok(());
}
queue!(self.out, BeginSynchronizedUpdate)?;
for op in ops {
match op {

View file

@ -66,8 +66,8 @@ fn a_one_cell_diff_is_one_synchronized_update_with_one_move() {
}
#[test]
fn no_ops_still_wrap_in_a_synchronized_update_and_say_nothing_else() {
assert_eq!(drawn(&[]), b"\x1b[?2026h\x1b[?2026l");
fn no_ops_write_nothing() {
assert_eq!(drawn(&[]), Vec::<u8>::new());
}
#[test]