Skip to content

fix nested table after wrapping/truncating changes - #19007

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_table_wrapping_bug
Sep 11, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_table_wrapping_bug

Conversation

@fdncred

@fdncred fdncred commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR tries to fix a bug where nested tables weren't wrapping properly.

User-facing changes (Release notes)

Expanded nested tables now keep their table borders when cells wrap

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.

Additional notes

closes #19002

@fdncred fdncred mentioned this pull request Sep 10, 2026
1 of 2 tasks
@fdncred
fdncred merged commit 164c9f2 into nushell:main Sep 11, 2026
15 checks passed
@fdncred
fdncred deleted the fix_table_wrapping_bug branch September 11, 2026 14:54
@github-actions github-actions Bot added this to the v0.116.0 milestone Sep 11, 2026
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Sep 14, 2026
fdncred added a commit that referenced this pull request Oct 21, 2026
…s everywhere (#19303)

## Description

Since #19007, `table --expand` squeezed short columns to 4 characters
whenever another column held a nested table. The nested-table column
took every spare character before any other column grew, so an `env`
listing printed `SOME_BIG_SESSION_ENV_VAR` as seven 4-character lines.
`table --expand` also ignored `metadata set
--table-width-priority-columns`. So did `table` at 120 columns or less,
unless wrapping and header-on-separator were both on.

An `env`-style listing with nested values, `table -e`, header on the
separator, 100 wide:

```nushell
$env.config.table.header_on_separator = true; [[key value]; [CLAUDE_CODE_CHILD_SESSION 1] [HOME /Users/fdncred] [PATH [/Users/fdncred/.local/bin /usr/local/bin /opt/homebrew/opt/python/libexec/bin /Users/fdncred/.cargo/bin /opt/homebrew/opt/uutils-coreutils/libexec/uubin]] [FPATH "/Users/fdncred/.grok/completions/zsh:/Users/fdncred/.zsh:/opt/homebrew/share/zsh/site-functions:/usr/local/share/zsh/site-functions"]] | table -e -w 100
```

Before:
```nushell
╭─#─┬─key──┬─────────────────────────────────────────value─────────────────────────────────────────╮
│ 0 │ CLAU │                                                                                     1 │
│   │ DE_C │                                                                                       │
│   │ ODE_ │                                                                                       │
│   │ CHIL │                                                                                       │
│   │ D_SE │                                                                                       │
│   │ SSIO │                                                                                       │
│   │ N    │                                                                                       │
│ 1 │ HOME │ /Users/fdncred                                                                        │
│ 2 │ PATH │ ╭───┬──────────────────────────────────────────────────╮                              │
│   │      │ │ 0 │ /Users/fdncred/.local/bin                        │                              │
│   │      │ │ 1 │ /usr/local/bin                                   │                              │
│   │      │ │ 2 │ /opt/homebrew/opt/python/libexec/bin             │                              │
│   │      │ │ 3 │ /Users/fdncred/.cargo/bin                        │                              │
│   │      │ │ 4 │ /opt/homebrew/opt/uutils-coreutils/libexec/uubin │                              │
│   │      │ ╰───┴──────────────────────────────────────────────────╯                              │
│ 3 │ FPAT │ /Users/fdncred/.grok/completions/zsh:/Users/fdncred/.zsh:/opt/homebrew/share/zsh/site │
│   │ H    │ -functions:/                                                                          │
│   │      │ usr/local/share/zsh/site-functions                                                    │
╰───┴──────┴───────────────────────────────────────────────────────────────────────────────────────╯
```

After:
```nushell
╭─#─┬────────────key────────────┬──────────────────────────────value───────────────────────────────╮
│ 0 │ CLAUDE_CODE_CHILD_SESSION │                                                                1 │
│ 1 │ HOME                      │ /Users/fdncred                                                   │
│ 2 │ PATH                      │ ╭───┬──────────────────────────────────────────────────╮         │
│   │                           │ │ 0 │ /Users/fdncred/.local/bin                        │         │
│   │                           │ │ 1 │ /usr/local/bin                                   │         │
│   │                           │ │ 2 │ /opt/homebrew/opt/python/libexec/bin             │         │
│   │                           │ │ 3 │ /Users/fdncred/.cargo/bin                        │         │
│   │                           │ │ 4 │ /opt/homebrew/opt/uutils-coreutils/libexec/uubin │         │
│   │                           │ ╰───┴──────────────────────────────────────────────────╯         │
│ 3 │ FPATH                     │ /Users/fdncred/.grok/completions/zsh:/Users/fdncred/.zsh:/opt/ho │
│   │                           │ mebrew/share/zsh/site-functions:/usr/local/share/zsh/site-functi │
│   │                           │ ons                                                              │
╰───┴───────────────────────────┴──────────────────────────────────────────────────────────────────╯
```

A `plugin list`-shaped table, `table -e`, 120 wide:

```nushell
[[name version status pid filename shell commands]; [dns 4.0.13-alpha.1 loaded null C:\Users\x\.cargo\bin\nu_plugin_dns.exe null [[name description]; ["dns query" "Perform a DNS query"]]] [file 0.27.0 loaded null C:\Users\x\.cargo\bin\nu_plugin_file.exe null [[name description]; [file "View file format information"]]]] | table -e -w 120
```

Before:
```nushell
╭───┬──────┬────────────────┬────────┬─────┬──────────────────────────────────────────┬───────┬────────────────────────╮
│ # │ name │    version     │ status │ pid │                 filename                 │ shell │        commands        │
├───┼──────┼────────────────┼────────┼─────┼──────────────────────────────────────────┼───────┼────────────────────────┤
│ 0 │ dns  │ 4.0.13-alpha.1 │ loaded │     │ C:\Users\x\.cargo\bin\nu_plugin_dns.exe  │       │ ╭───┬───────────╮      │
│   │      │                │        │     │                                          │       │ │ # │   name    │      │
│   │      │                │        │     │                                          │       │ ├───┼───────────┤      │
│   │      │                │        │     │                                          │       │ │ 0 │ dns query │      │
│   │      │                │        │     │                                          │       │ ╰───┴───────────╯      │
│ 1 │ file │ 0.27.0         │ loaded │     │ C:\Users\x\.cargo\bin\nu_plugin_file.exe │       │ ╭───┬──────┬─────────╮ │
│   │      │                │        │     │                                          │       │ │ # │ name │ descrip │ │
│   │      │                │        │     │                                          │       │ │   │      │ tion    │ │
│   │      │                │        │     │                                          │       │ ├───┼──────┼─────────┤ │
│   │      │                │        │     │                                          │       │ │ 0 │ file │ View    │ │
│   │      │                │        │     │                                          │       │ │   │      │ file    │ │
│   │      │                │        │     │                                          │       │ │   │      │ format  │ │
│   │      │                │        │     │                                          │       │ │   │      │ informa │ │
│   │      │                │        │     │                                          │       │ │   │      │ tion    │ │
│   │      │                │        │     │                                          │       │ ╰───┴──────┴─────────╯ │
╰───┴──────┴────────────────┴────────┴─────┴──────────────────────────────────────────┴───────┴────────────────────────╯
```

After:
```nushell
╭───┬──────┬────────────────┬────────┬─────┬─────────────────────────────────┬───────┬─────────────────────────────────╮
│ # │ name │    version     │ status │ pid │            filename             │ shell │            commands             │
├───┼──────┼────────────────┼────────┼─────┼─────────────────────────────────┼───────┼─────────────────────────────────┤
│ 0 │ dns  │ 4.0.13-alpha.1 │ loaded │     │ C:\Users\x\.cargo\bin\nu_plugin │       │ ╭───┬───────────┬─────────────╮ │
│   │      │                │        │     │ _dns.exe                        │       │ │ # │   name    │ description │ │
│   │      │                │        │     │                                 │       │ ├───┼───────────┼─────────────┤ │
│   │      │                │        │     │                                 │       │ │ 0 │ dns query │ Perform a   │ │
│   │      │                │        │     │                                 │       │ │   │           │ DNS query   │ │
│   │      │                │        │     │                                 │       │ ╰───┴───────────┴─────────────╯ │
│ 1 │ file │ 0.27.0         │ loaded │     │ C:\Users\x\.cargo\bin\nu_plugin │       │ ╭───┬──────┬──────────────────╮ │
│   │      │                │        │     │ _file.exe                       │       │ │ # │ name │   description    │ │
│   │      │                │        │     │                                 │       │ ├───┼──────┼──────────────────┤ │
│   │      │                │        │     │                                 │       │ │ 0 │ file │ View file format │ │
│   │      │                │        │     │                                 │       │ │   │      │  information     │ │
│   │      │                │        │     │                                 │       │ ╰───┴──────┴──────────────────╯ │
╰───┴──────┴────────────────┴────────┴─────┴─────────────────────────────────┴───────┴─────────────────────────────────╯
```

A record with a 100-character key, `table -w 60`:

```nushell
{("k" | fill -c k -w 100): 1, b: 2} | table -w 60
```

Before:
```nushell
╭────────────────────────────────────────────────────┬─────╮
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk │ ... │
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk │     │
│ b                                                  │ ... │
╰────────────────────────────────────────────────────┴─────╯
```

After:
```nushell
╭──────────────────────────────────────────────────────┬───╮
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk │ 1 │
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk     │   │
│ b                                                    │ 2 │
╰──────────────────────────────────────────────────────┴───╯
```

CJK headers with `header_on_separator`, `table -e`: This intentionally
doesn't draw the characters on the headers, even when the setting is set
to true, in order to avoid misaligned tables. (images convey this better
below)

```nushell
$env.config.table.header_on_separator = true; [[id 名前 inner]; [1 漢字 [[鍵 a]; [x 1]]]] | table -e
```

Before:
<img width="1672" height="718" alt="image"
src="https://github.com/user-attachments/assets/773cd8f2-9fe1-4185-bf0c-c0a1637e7deb"
/>

After:
<img width="1672" height="924" alt="image"
src="https://github.com/user-attachments/assets/09cdbc27-0425-4547-a8e2-902ff725e6dd"
/>



## User-facing changes (Release notes)

- `table` and `table --expand` shrink the widest columns first, so short
columns such as keys, names and sizes keep their width next to long text
or nested tables.
- `metadata set --table-width-priority-columns`, which `ls` and `ps`
also set, now works with `table --expand` and at every terminal width. A
priority column shows wherever it would without the priority, and
columns to its right hide to leave it up to a third of the table width.
- `table --expand` draws a nested table whenever it fits, hiding columns
to its right first and collapsing the nested table's own columns behind
`...`, instead of showing `[table N rows]`. Nested tables no longer drop
columns without a `...` marker.
- Tables keep each visible column at least 10 characters wide (or its
natural width), hiding columns from the right when they don't fit.
Without `header_on_separator` this shows more columns on narrow
terminals; with it, fewer, since columns are no longer squeezed to 4
characters.
- Record keys wrap when a key is too long for the terminal, instead of
hiding the values.
- With `header_on_separator`, headers with CJK characters, emoji or
Arabic ligatures are drawn in their own row, so the table border lines
up.

## Additional notes
<!--
Optional.

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

Anything else reviewers should know.
Remove this section if not needed.
-->
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 wrapping error

1 participant