nu-table: Remove safety-net width check (#15901)

I think we must be relatively confident to say at the check point we
build correct table.
There must be no point endlessly recheck stuff.
This commit is contained in:
Maxim Zhiburt 2025-06-13 02:22:02 +03:00 committed by GitHub
parent 0e46ef9769
commit 4aeede2dd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -475,7 +475,8 @@ fn draw_table(
truncate_table(&mut table, &t.config, width, termwidth);
table_set_border_header(&mut table, head, &t.config);
table_to_string(table, termwidth)
let string = table.to_string();
Some(string)
}
fn set_styles(table: &mut Table, styles: Styles, structure: &TableStructure) {
@ -531,18 +532,6 @@ fn set_indent(table: &mut Table, indent: TableIndent) {
table.with(Padding::new(indent.left, indent.right, 0, 0));
}
fn table_to_string(table: Table, termwidth: usize) -> Option<String> {
// Note: this is a "safe" path; presumable it must never happen cause we must made all the checks already
// TODO: maybe remove it? I think so?
let total_width = table.total_width();
if total_width > termwidth {
None
} else {
let content = table.to_string();
Some(content)
}
}
struct WidthCtrl {
width: WidthEstimation,
trim_strategy: TrimStrategy,
@ -915,7 +904,9 @@ fn truncate_columns_by_content(
widths.push(trailing_column_width);
width += trailing_column_width;
if widths.len() == 1 {
let has_only_trail = widths.len() == 1;
let is_enough_space = width <= termwidth;
if has_only_trail || !is_enough_space {
// nothing to show anyhow
return WidthEstimation::new(widths_original, vec![], width, false, true);
}