nu-table: Don't add an empty column if there is only 1 column (#17013)

Basically sets the `WidthEstimation`'s `trail` value to false when there
is only one row column.

Test:
```nu
nu --no-config-file -c 'do {||
    $env.config.table = {
        trim: {methodology: "wrapping" wrapping_try_keep_words: true}
        padding: {left: 0 right: 0}
        mode = "none"
    }
    ["long string with a break around this po_int, near the underscore"]
    | table --width 40 --index=false
}'
```

Previous output:
```
long string with a break around this ...
 po_int, near the underscore
```

With this change:
```
long string with a break around this
po_int, near the underscore
```

## Release notes summary - What our users need to know
NaN

## Tasks after submitting
NaN
This commit is contained in:
Kai Sforza
2025-11-23 11:16:09 +08:00
committed by GitHub
parent 48d63dfdd0
commit e3d66523e6
2 changed files with 196 additions and 26 deletions
+2 -4
View File
@@ -875,11 +875,9 @@ fn truncate_columns_by_content(
if i > 0 {
next_move += vertical;
}
if width + next_move > termwidth {
break;
}
widths.push(column_width);
width += next_move;
truncate_pos += 1;
@@ -889,7 +887,8 @@ fn truncate_columns_by_content(
return WidthEstimation::new(widths_original, widths, width, false, false);
}
if truncate_pos == 0 {
let is_last_column = truncate_pos + 1 == count_columns;
if truncate_pos == 0 && !is_last_column {
if termwidth > width {
let available = termwidth - width;
if available >= min_column_width + vertical + trailing_column_width {
@@ -912,7 +911,6 @@ fn truncate_columns_by_content(
let available = termwidth - width;
let is_last_column = truncate_pos + 1 == count_columns;
let can_fit_last_column = available >= min_column_width + vertical;
if is_last_column && can_fit_last_column {
let w = available - vertical;
File diff suppressed because one or more lines are too long