From 0a07e8dbdf48d3bc8c2f2ba001c8f85033bf2683 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 15 Mar 2026 19:59:08 +0100 Subject: [PATCH] pager: set col width only once a bit hidden when column width is overwritten afterwards Closes #12546 --- src/pager.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pager.rs b/src/pager.rs index e61bf1bdd..7dd742587 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -225,22 +225,18 @@ fn completion_try_print( max_desc = max_desc.max(c.description_punctuated_width()); } *col = Column { - width: max_comp + max_desc, + // Force-fit to term width, useful when one column. + width: (max_comp + max_desc).min(term_width), desc_align: max_comp + 2, }; } + let cols = cols; // rm mut - let print = if col_count == 1 { - // Force fit if one column. - cols[0].width = std::cmp::min(cols[0].width, term_width); - true - } else { - // Compute total preferred width, plus spacing - let mut total_width_needed: usize = cols.iter().map(|c| c.width).sum(); - total_width_needed += (col_count - 1) * PAGER_SPACER_STRING.len(); - total_width_needed <= term_width - }; - if !print { + // Compute total preferred width, plus spacing + let total_width_needed = cols.iter().map(|c| c.width).sum::() + + (col_count - 1) * PAGER_SPACER_STRING.len(); + if term_width < total_width_needed { + assert!(col_count > 1, "single col force-fit to termwidth above"); return false; // no need to continue }