Skip to content

fix(table): shrink the widest columns first and honor width priorities everywhere - #19303

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_table_column_widths
Oct 21, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_table_column_widths

Conversation

@fdncred

@fdncred fdncred commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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:

$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:

╭─#─┬─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:

╭─#─┬────────────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:

[[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:

╭───┬──────┬────────────────┬────────┬─────┬──────────────────────────────────────────┬───────┬────────────────────────╮
│ # │ 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:

╭───┬──────┬────────────────┬────────┬─────┬─────────────────────────────────┬───────┬─────────────────────────────────╮
│ # │ 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:

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

Before:

╭────────────────────────────────────────────────────┬─────╮
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk │ ... │
│ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk │     │
│ b                                                  │ ... │
╰────────────────────────────────────────────────────┴─────╯

After:

╭──────────────────────────────────────────────────────┬───╮
│ 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)

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

Before:
image

After:
image

User-facing changes (Release notes)

table shrinks the widest columns first and honors width priorities everywhere

  • 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

@fdncred
fdncred merged commit f196eaf into nushell:main Oct 21, 2026
12 checks passed
@fdncred
fdncred deleted the fix_table_column_widths branch October 21, 2026 14:10
@github-actions github-actions Bot added this to the v0.117.0 milestone Oct 21, 2026
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Nov 1, 2026
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.

1 participant