From 496a385c15d04674257b7d4e8daa5277908b834d Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sun, 5 Apr 2026 14:05:33 -0700 Subject: [PATCH] fix(ui): prevent grid column overflow with proper truncation Fix column header and cell text truncation to prevent overflow when text width equals column width. Changed truncate() calls to use cw.saturating_sub(1) instead of cw, ensuring at least one character of padding remains. Affected areas: - Column header labels (left-aligned) - Column header labels (right-aligned) - Cell values - Total/summary rows Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M) --- src/ui/grid.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ui/grid.rs b/src/ui/grid.rs index 60229fd..17bdde6 100644 --- a/src/ui/grid.rs +++ b/src/ui/grid.rs @@ -218,7 +218,7 @@ impl<'a> GridWidget<'a> { buf.set_string( x, y, - format!("{: GridWidget<'a> { buf.set_string( x, y, - format!("{:>width$}", truncate(&label, cw), width = cw), + format!("{:>width$}", truncate(&label, cw.saturating_sub(1)), width = cw), styled, ); } @@ -434,7 +434,11 @@ impl<'a> GridWidget<'a> { buf.set_string( x, y, - format!("{:>width$}", truncate(&cell_str, cw), width = cw), + format!( + "{:>width$}", + truncate(&cell_str, cw.saturating_sub(1)), + width = cw + ), cell_style, ); } @@ -495,7 +499,11 @@ impl<'a> GridWidget<'a> { buf.set_string( x, y, - format!("{:>width$}", truncate(&total_str, cw), width = cw), + format!( + "{:>width$}", + truncate(&total_str, cw.saturating_sub(1)), + width = cw + ), Style::default() .fg(Color::Yellow) .add_modifier(Modifier::BOLD),