From b69203903fd18cf4b005220eefae5aa2b1325ca7 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Tue, 30 Dec 2025 21:44:07 +0100 Subject: [PATCH] lib/ui: Spacing must be explicitely set for table --- bin/commands/inbox/list.rs | 1 + bin/commands/issue/list.rs | 1 + bin/commands/patch/list.rs | 1 + bin/commands/patch/review.rs | 1 + bin/ui/im.rs | 1 + examples/selection.rs | 1 + src/ui/im.rs | 5 ++++- src/ui/im/widget.rs | 9 ++++++++- 8 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/commands/inbox/list.rs b/bin/commands/inbox/list.rs index 39334166..6e090b6a 100644 --- a/bin/commands/inbox/list.rs +++ b/bin/commands/inbox/list.rs @@ -373,6 +373,7 @@ impl App { ¬ifs, header.to_vec(), Some("".into()), + Spacing::from(1), Some(Borders::BottomSides), ); if table.changed { diff --git a/bin/commands/issue/list.rs b/bin/commands/issue/list.rs index ea4bc54b..f01aaf37 100644 --- a/bin/commands/issue/list.rs +++ b/bin/commands/issue/list.rs @@ -1361,6 +1361,7 @@ pub mod v2 { &issues, header.to_vec(), None, + Spacing::from(1), Some(Borders::BottomSides), ); if table.changed { diff --git a/bin/commands/patch/list.rs b/bin/commands/patch/list.rs index 12cde3c2..221a975f 100644 --- a/bin/commands/patch/list.rs +++ b/bin/commands/patch/list.rs @@ -343,6 +343,7 @@ impl App { &patches, header.to_vec(), Some("No patches found".into()), + Spacing::from(1), Some(Borders::BottomSides), ); if table.changed { diff --git a/bin/commands/patch/review.rs b/bin/commands/patch/review.rs index af96306f..0b0a5f03 100644 --- a/bin/commands/patch/review.rs +++ b/bin/commands/patch/review.rs @@ -354,6 +354,7 @@ impl App<'_> { &hunks, columns, None, + Spacing::from(1), Some(Borders::BottomSides), ); if table.changed { diff --git a/bin/ui/im.rs b/bin/ui/im.rs index 1dbbd635..abcaa0d7 100644 --- a/bin/ui/im.rs +++ b/bin/ui/im.rs @@ -138,6 +138,7 @@ where self.items, self.header.to_vec(), None, + Spacing::from(1), if *self.show_search { Some(Borders::BottomSides) } else { diff --git a/examples/selection.rs b/examples/selection.rs index 9feb2e40..406f717e 100644 --- a/examples/selection.rs +++ b/examples/selection.rs @@ -109,6 +109,7 @@ impl Show for App { &self.items, columns, None, + Spacing::from(1), Some(Borders::None), ); if table.changed { diff --git a/src/ui/im.rs b/src/ui/im.rs index 20750bb9..5fb82e76 100644 --- a/src/ui/im.rs +++ b/src/ui/im.rs @@ -558,12 +558,15 @@ where items: &'a Vec, columns: Vec>, empty_message: Option, + spacing: Spacing, borders: Option, ) -> Response where R: ToRow + Clone, { - widget::Table::new(selected, items, columns, empty_message, borders).ui(self, frame) + widget::Table::new(selected, items, columns, empty_message, borders) + .spacing(spacing) + .ui(self, frame) } pub fn shortcuts( diff --git a/src/ui/im/widget.rs b/src/ui/im/widget.rs index 324b1263..fdeeeb12 100644 --- a/src/ui/im/widget.rs +++ b/src/ui/im/widget.rs @@ -308,6 +308,7 @@ pub struct Table<'a, R, const W: usize> { items: &'a Vec, selected: &'a mut Option, columns: Vec>, + spacing: Spacing, borders: Option, show_scrollbar: bool, empty_message: Option, @@ -329,6 +330,7 @@ where items, selected, columns, + spacing: Spacing::from(1), empty_message, borders, show_scrollbar: true, @@ -340,6 +342,11 @@ where self.dim = dim; self } + + pub fn spacing(mut self, spacing: Spacing) -> Self { + self.spacing = spacing; + self + } } impl Widget for Table<'_, R, W> @@ -446,7 +453,7 @@ where let table = ratatui::widgets::Table::default() .rows(rows) .widths(widths) - .column_spacing(1) + .column_spacing(self.spacing.into()) .row_highlight_style(style::highlight(area_focus)); let table = if !area_focus && self.dim {