Repository navigation
fix nested table after wrapping/truncating changes - #19007
Merged
Merged
Conversation
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. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --expandwrapping nested tables as text, which broke their borders (for exampleplugin listafter #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