From 36f3e5105ce3d70edc630698066e69b86aaf21e6 Mon Sep 17 00:00:00 2001 From: euxaristia Date: Sat, 22 Aug 2026 02:29:09 -0400 Subject: [PATCH] Clear the terminal buffer when the viewport is resized. Growing the terminal exposes cells that ratatui never repaints, because the frame-wide Clear in draw() only covers the area it currently believes is the viewport. Wipe the whole buffer on Event::Resize so the next frame starts clean instead of painting around leftover text. Refs #34 Claude-Session: https://claude.ai/code/session_01PvhTkPF3fvjPUh5ao9MeWL --- src/tui.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tui.rs b/src/tui.rs index db02f12..a75e4c4 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -612,12 +612,16 @@ fn event_loop( if !event::poll(FRAME)? { continue; } - let Event::Key(key) = event::read()? else { - continue; + let key = match event::read()? { + // A resize leaves stale cells outside the new viewport, so wipe the + // buffer instead of painting the next frame over them. + Event::Resize(..) => { + terminal.clear()?; + continue; + } + Event::Key(key) if key.kind == KeyEventKind::Press => key, + _ => continue, }; - if key.kind != KeyEventKind::Press { - continue; - } app.message = None; match key.code {