tui: fix scroll by using Paragraph::line_count()

Replace homegrown wrapping math (wrapped_height, wrapped_height_line,
auto_scroll, force_scroll, wrapped_line_count) with ratatui's own
Paragraph::line_count() which exactly matches its rendering. The old
approach used ceiling division that didn't account for word wrapping,
causing bottom content to be clipped.

Also add terminal.clear() on resize to force full redraw — fixes the
TUI rendering at old canvas size after terminal resize.

Requires the unstable-rendered-line-info feature flag on ratatui.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kent Overstreet 2026-03-20 12:16:35 -04:00
parent 6d22f70192
commit f45f663dc0
3 changed files with 30 additions and 65 deletions

View file

@ -1033,7 +1033,10 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
Some(Ok(Event::Mouse(mouse))) => {
app.handle_mouse(mouse);
}
Some(Ok(Event::Resize(_, _))) => {}
Some(Ok(Event::Resize(w, h))) => {
app.handle_resize(w, h);
terminal.clear()?;
}
Some(Err(_)) => break,
None => break,
_ => continue,