Skip to content

fix table truncating vs wrapping - #18979

Merged
fdncred merged 2 commits into
nushell:mainfrom
fdncred:fix_table_wrapping_vs_truncating
Sep 8, 2026
Merged

fdncred merged 2 commits into
nushell:mainfrom
fdncred:fix_table_wrapping_vs_truncating

Conversation

@fdncred

@fdncred fdncred commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

At some point in time table column truncating vs column wrapping was broken.

$env.config.table.trim is supposed to control how a visible column that is narrower than its content is fitted:

  • wrapping: stack overflow onto extra lines (optionally keeping words)
  • truncating: keep the row on one line and cut the cell, appending truncating_suffix

That did not work in the cases people actually hit.

This PR tries to fix that problem.

User-facing changes (Release notes)

Table display now respects $env.config.table.trim wrapping and truncating more consistently

Fixed $env.config.table.trim so wrapping and truncating actually differ on default table display (table -e on terminals 100 columns or wider), including with header_on_separator.

  • wrapping: more columns; long cells wrap onto extra lines.
  • truncating: one line per row; extra columns dropped with a trailing ...; a squeezed cell gets truncating_suffix.
  • Columns are no longer squeezed to a single character (the size / s/i/z/e ladder).
  • The trailing ... column is not truncating_suffix. That suffix only appears when a visible cell is cut.

Example:

wrapping

~/src/nushell> $env.config.table.trim = { methodology: wrapping, truncating_suffix: "..." }
~/src/nushell> ls -al
╭────┬───────────────┬─────────┬───────────┬──────────┬───────────┬───────────┬───────────┬─────────┬───────┬──────────┬────────────┬─────╮
│  # │     name      │  type   │  target   │ readonly │   mode    │ num_links │   inode   │  user   │ group │   size   │  created   │ ... │
├────┼───────────────┼─────────┼───────────┼──────────┼───────────┼───────────┼───────────┼─────────┼───────┼──────────┼────────────┼─────┤
│  0 │ .DS_Store     │ file    │           │ false    │ rw-r--r-- │         1 │ 105784265 │ fdncred │ staff │   6.1 kB │ 2 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  1 │ .cargo        │ dir     │           │ false    │ rwxr-xr-x │         5 │ 104748545 │ fdncred │ staff │    160 B │ 2 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  2 │ .git          │ dir     │           │ false    │ rwxr-xr-x │        20 │ 104748469 │ fdncred │ staff │    640 B │ 2 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  3 │ .gitattribute │ file    │           │ false    │ rw-r--r-- │         1 │ 104748547 │ fdncred │ staff │    111 B │ 2 years    │ ... │
│    │ s             │         │           │          │           │           │           │         │       │          │ ago        │     │
│  4 │ .githooks     │ dir     │           │ false    │ rwxr-xr-x │         4 │ 104748548 │ fdncred │ staff │    128 B │ 2 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  5 │ .github       │ dir     │           │ false    │ rwxr-xr-x │         9 │ 104748551 │ fdncred │ staff │    288 B │ 2 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  6 │ .gitignore    │ file    │           │ false    │ rw-r--r-- │         1 │ 225043642 │ fdncred │ staff │    831 B │ a month    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  7 │ .idea         │ dir     │           │ false    │ rwxr-xr-x │         7 │ 133567994 │ fdncred │ staff │    224 B │ a year ago │ ... │
│  8 │ .mailmap      │ file    │           │ false    │ rw-r--r-- │         1 │ 110444015 │ fdncred │ staff │   2.1 kB │ 4 years    │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │
│  9 │ .opencode     │ dir     │           │ false    │ rwxr-xr-x │         6 │ 209157307 │ fdncred │ staff │    192 B │ 2 months   │ ... │
│    │               │         │           │          │           │           │           │         │       │          │ ago        │     │

truncating

~/src/nushell> $env.config.table.trim = { methodology: truncating, truncating_suffix: "..." }
~/src/nushell> ls -al
╭────┬──────────────────────────────────────────┬─────────┬───────────┬──────────┬───────────┬───────────┬───────────┬─────────┬───────┬─────╮
│  # │                   name                   │  type   │  target   │ readonly │   mode    │ num_links │   inode   │  user   │ group │ ... │
├────┼──────────────────────────────────────────┼─────────┼───────────┼──────────┼───────────┼───────────┼───────────┼─────────┼───────┼─────┤
│  0 │ .DS_Store                                │ file    │           │ false    │ rw-r--r-- │         1 │ 105784265 │ fdncred │ staff │ ... │
│  1 │ .cargo                                   │ dir     │           │ false    │ rwxr-xr-x │         5 │ 104748545 │ fdncred │ staff │ ... │
│  2 │ .git                                     │ dir     │           │ false    │ rwxr-xr-x │        20 │ 104748469 │ fdncred │ staff │ ... │
│  3 │ .gitattributes                           │ file    │           │ false    │ rw-r--r-- │         1 │ 104748547 │ fdncred │ staff │ ... │
│  4 │ .githooks                                │ dir     │           │ false    │ rwxr-xr-x │         4 │ 104748548 │ fdncred │ staff │ ... │
│  5 │ .github                                  │ dir     │           │ false    │ rwxr-xr-x │         9 │ 104748551 │ fdncred │ staff │ ... │
│  6 │ .gitignore                               │ file    │           │ false    │ rw-r--r-- │         1 │ 225043642 │ fdncred │ staff │ ... │
│  7 │ .idea                                    │ dir     │           │ false    │ rwxr-xr-x │         7 │ 133567994 │ fdncred │ staff │ ... │
│  8 │ .mailmap                                 │ file    │           │ false    │ rw-r--r-- │         1 │ 110444015 │ fdncred │ staff │ ... │
│  9 │ .opencode                                │ dir     │           │ false    │ rwxr-xr-x │         6 │ 209157307 │ fdncred │ staff │ ... │

Additional notes

closes #18966

@fdncred
fdncred merged commit 6312a79 into nushell:main Sep 8, 2026
14 checks passed
@fdncred
fdncred deleted the fix_table_wrapping_vs_truncating branch September 8, 2026 11:39
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Sep 8, 2026
@github-actions github-actions Bot added this to the v0.116.0 milestone Sep 8, 2026
@Paul-16098 Paul-16098 mentioned this pull request Sep 10, 2026
1 of 2 tasks
fdncred added a commit that referenced this pull request Sep 11, 2026
<!--
Thanks for contributing to Nushell!

Before submitting, please read the contributing guide:
https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md

This template helps reviewers understand your changes and allows us to
generate high-quality release notes.
-->

## Description
This PR tries to fix a bug where nested tables weren't wrapping
properly.
<!--
Explain what this PR does and why.

This section is intentionally flexible:
- Describe the problem
- Explain your approach
- Include technical details if relevant

Good examples:
- "In this PR, I fixed..."
- "In this PR, I added support for..."
- "This change improves X by..."

Write as much or as little as needed for reviewers to understand your
changes.
-->

## User-facing changes (Release notes)

Fixed `table --expand` wrapping nested tables as text, which broke their
borders (for example `plugin list` after #18979).

Long cells in nested tables still wrap or truncate **inside** the inner
table according to `$env.config.table.trim`. The inner box stays a
table. Scalar columns on the parent still wrap or truncate the same way
as in #18979.

<!--
This section is used (mostly as-is) for https://www.nushell.sh/blog/

Describe how Nushell behavior changes from a user's perspective.
Do NOT describe internal Rust changes here.

Write in a release note style, for example:
- "Added support for..."
- "Fixed an issue where..."
- "Nushell now supports..."
- "Improved performance of..."

If your changes do NOT affect users (internal refactors, cleanup, etc.),
just write:
- "n/a"
- "nan"
- or similar

This tells us the change should not appear in the changelog.

Tips:
- Focus on observable behavior
- Include examples if helpful
- Keep it concise

You can:
- Write a short paragraph (will appear as a bullet point), OR
- Use headings (###) if your change needs more structure

Avoid writing things like:
- "In this PR, I refactored..."
- "This updates internal code..."

You may leave this blank until the PR is ready.
-->

## Additional notes
closes #19002
<!--
Optional.

Examples:
- fixes #123
- closes #456
- related #789

Anything else reviewers should know.
Remove this section if not needed.
-->
fdncred pushed a commit that referenced this pull request Sep 23, 2026
…19066)

With `$env.config.table.header_on_separator = true`, the `markdown` and
`restructured` themes drew the header inside the top border, which
produces invalid markup:

```
|-#-|-a-|-b-|
| 0 | 1 | 2 |
```

```
=#= =a= =b=
 0   1   2
=== === ===
```

These two themes exist to emit markup that other tools parse, so as
suggested in #13161, `configure_table` now ignores `header_on_separator`
for them. Every table goes through `configure_table` (general and
`--expand`), so this covers both. Other themes are unchanged.

After:

```
| # | a | b |
|---|---|---|
| 0 | 1 | 2 |
```

`wrap_and_truncate_differ_for_every_theme_with_header_on_separator`
(from #18979) no longer lists `markdown` and `restructured`. With the
header in its own row, wrapping and truncating give identical output for
this data on every theme (e.g. `rounded` with `header_on_separator =
false`), because overflowing columns are replaced with `...`. The two
only differ in the header-on-border layout, which these themes no longer
use.

## User-facing changes (Release notes)

`table --theme markdown` and `table --theme restructured` (and the
matching `$env.config.table.mode` values) now always produce valid
Markdown / reStructuredText, even when
`$env.config.table.header_on_separator` is enabled.

## Tests + Formatting

- Added `table_markup_themes_ignore_header_on_separator`. It fails
without this change (`|-#-|-a-|-b-|`) and passes with it.
- `cargo test -p nu-command --test tests -- commands::table::`: 492
passed
- `cargo fmt --all -- --check`
- `cargo clippy -p nu-table -p nu-command --all-targets -- -D warnings
-D clippy::unwrap_used`

## Additional notes

Fixes #13161

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table cell still wrapping when using methodology: "truncating" in $env.config.table.trim

1 participant