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)
This commit is contained in:
Edward Langley
2026-04-05 14:05:33 -07:00
parent cc6504e9b6
commit 496a385c15

View File

@ -218,7 +218,7 @@ impl<'a> GridWidget<'a> {
buf.set_string( buf.set_string(
x, x,
y, y,
format!("{:<width$}", truncate(&label, cw), width = cw), format!("{:<width$}", truncate(&label, cw.saturating_sub(1)), width = cw),
group_style, group_style,
); );
} }
@ -260,7 +260,7 @@ impl<'a> GridWidget<'a> {
buf.set_string( buf.set_string(
x, x,
y, y,
format!("{:>width$}", truncate(&label, cw), width = cw), format!("{:>width$}", truncate(&label, cw.saturating_sub(1)), width = cw),
styled, styled,
); );
} }
@ -434,7 +434,11 @@ impl<'a> GridWidget<'a> {
buf.set_string( buf.set_string(
x, x,
y, y,
format!("{:>width$}", truncate(&cell_str, cw), width = cw), format!(
"{:>width$}",
truncate(&cell_str, cw.saturating_sub(1)),
width = cw
),
cell_style, cell_style,
); );
} }
@ -495,7 +499,11 @@ impl<'a> GridWidget<'a> {
buf.set_string( buf.set_string(
x, x,
y, y,
format!("{:>width$}", truncate(&total_str, cw), width = cw), format!(
"{:>width$}",
truncate(&total_str, cw.saturating_sub(1)),
width = cw
),
Style::default() Style::default()
.fg(Color::Yellow) .fg(Color::Yellow)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),