This addresses color issue; Yeees just got forgotten it :(
As far as I understand an acceptance test can't be created because ansi
got stripped in `nu!`. (for future regressions)

But wrapping I need to take a deeper look.
Maybe in an hour.

cc: @fdncred
This commit is contained in:
Maxim Zhiburt 2025-04-11 16:02:01 +03:00 committed by GitHub
parent 39edd7e080
commit d75aa7ed1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 805 additions and 793 deletions

View File

@ -1333,7 +1333,15 @@ fn test_expand_big_0() {
"│ target │ {record 3 fields} │",
"│ dev-dependencies │ {record 9 fields} │",
"│ features │ {record 8 fields} │",
"│ bin │ [table 1 row] │",
"│ │ ╭───┬─────┬─────╮ │",
"│ bin │ │ # │ nam │ pat │ │",
"│ │ │ │ e │ h │ │",
"│ │ ├───┼─────┼─────┤ │",
"│ │ │ 0 │ nu │ src │ │",
"│ │ │ │ │ /ma │ │",
"│ │ │ │ │ in. │ │",
"│ │ │ │ │ rs │ │",
"│ │ ╰───┴─────┴─────╯ │",
"│ │ ╭───────────┬───╮ │",
"│ patch │ │ crates-io │ { │ │",
"│ │ │ │ r │ │",
@ -1352,7 +1360,16 @@ fn test_expand_big_0() {
"│ │ │ │ d │ │",
"│ │ │ │ } │ │",
"│ │ ╰───────────┴───╯ │",
"│ bench │ [table 1 row] │",
"│ │ ╭───┬─────┬─────╮ │",
"│ bench │ │ # │ nam │ har │ │",
"│ │ │ │ e │ nes │ │",
"│ │ │ │ │ s │ │",
"│ │ ├───┼─────┼─────┤ │",
"│ │ │ 0 │ ben │ fal │ │",
"│ │ │ │ chm │ se │ │",
"│ │ │ │ ark │ │ │",
"│ │ │ │ s │ │ │",
"│ │ ╰───┴─────┴─────╯ │",
"╰──────────────────┴───────────────────╯",
]);
@ -1366,6 +1383,8 @@ fn table_expande_with_no_header_internally_0() {
let actual = nu!(format!("{} | table --expand --width 141", nu_value.trim()));
_print_lines(&actual.out, 141);
assert_eq!(
actual.out,
join_lines([
@ -1532,71 +1551,191 @@ fn table_expande_with_no_header_internally_0() {
"│ │ │ │ │ │ ╰─────┴──────────╯ │ │ │",
"│ │ │ │ │ display_output │ │ │ │",
"│ │ │ │ ╰────────────────┴────────────────────╯ │ │",
"│ │ │ │ ╭───┬───────────────────────────┬────────────────────────┬────────┬─────╮ │ │",
"│ │ │ menus │ │ # │ name │ only_buffer_difference │ marker │ ... │ │ │",
"│ │ │ │ ├───┼───────────────────────────┼────────────────────────┼────────┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ false │ | │ ... │ │ │",
"│ │ │ │ │ 1 │ history_menu │ true │ ? │ ... │ │ │",
"│ │ │ │ │ 2 │ help_menu │ true │ ? │ ... │ │ │",
"│ │ │ │ │ 3 │ commands_menu │ false │ # │ ... │ │ │",
"│ │ │ │ │ 4 │ vars_menu │ true │ # │ ... │ │ │",
"│ │ │ │ │ 5 │ commands_with_description │ true │ # │ ... │ │ │",
"│ │ │ │ ╰───┴───────────────────────────┴────────────────────────┴────────┴─────╯ │ │",
"│ │ │ │ ╭───┬───────────────────────────┬────────────────────────┬────────┬───┬─────╮ │ │",
"│ │ │ menus │ │ # │ name │ only_buffer_difference │ marker │ t │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ y │ │ │ │",
"│ │ │ │ │ │ │ │ │ p │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ ├───┼───────────────────────────┼────────────────────────┼────────┼───┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ false │ | │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 4 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ │ 1 │ history_menu │ true │ ? │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 2 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ │ 2 │ help_menu │ true │ ? │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 6 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ │ 3 │ commands_menu │ false │ # │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 4 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ │ 4 │ vars_menu │ true │ # │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 2 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ │ 5 │ commands_with_description │ true │ # │ { │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ c │ │ │ │",
"│ │ │ │ │ │ │ │ │ o │ │ │ │",
"│ │ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ 6 │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ f │ │ │ │",
"│ │ │ │ │ │ │ │ │ i │ │ │ │",
"│ │ │ │ │ │ │ │ │ e │ │ │ │",
"│ │ │ │ │ │ │ │ │ l │ │ │ │",
"│ │ │ │ │ │ │ │ │ d │ │ │ │",
"│ │ │ │ │ │ │ │ │ s │ │ │ │",
"│ │ │ │ │ │ │ │ │ } │ │ │ │",
"│ │ │ │ ╰───┴───────────────────────────┴────────────────────────┴────────┴───┴─────╯ │ │",
"│ │ │ │ ╭────┬───────────────────────────┬──────────┬─────────┬───────────────┬─────╮ │ │",
"│ │ │ keybindings │ │ # │ name │ modifier │ keycode │ mode │ ... │ │ │",
"│ │ │ keybindings │ │ # │ name │ modifier │ keycode │ mode │ eve │ │ │",
"│ │ │ │ │ │ │ │ │ │ nt │ │ │",
"│ │ │ │ ├────┼───────────────────────────┼──────────┼─────────┼───────────────┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ none │ tab │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 0 │ completion_menu │ none │ tab │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ } │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 1 │ completion_previous │ shift │ backtab │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 1 │ completion_previous │ shift │ backtab │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ } │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 2 │ history_menu │ control │ char_r │ emacs │ ... │ │ │",
"│ │ │ │ │ 3 │ next_page │ control │ char_x │ emacs │ ... │ │ │",
"│ │ │ │ │ 4 │ undo_or_previous_page │ control │ char_z │ emacs │ ... │ │ │",
"│ │ │ │ │ 5 │ yank │ control │ char_y │ emacs │ ... │ │ │",
"│ │ │ │ │ 6 │ unix-line-discard │ control │ char_u │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 2 │ history_menu │ control │ char_r │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ s} │ │ │",
"│ │ │ │ │ 3 │ next_page │ control │ char_x │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 4 │ undo_or_previous_page │ control │ char_z │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 5 │ yank │ control │ char_y │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 6 │ unix-line-discard │ control │ char_u │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ } │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 7 │ kill-line │ control │ char_k │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 7 │ kill-line │ control │ char_k │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ } │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 8 │ commands_menu │ control │ char_t │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 8 │ commands_menu │ control │ char_t │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ s} │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 9 │ vars_menu │ alt │ char_o │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 9 │ vars_menu │ alt │ char_o │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ s} │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ │ 10 │ commands_with_description │ control │ char_s │ ╭───┬───────╮ │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ │ │ │",
"│ │ │ │ │ 10 │ commands_with_description │ control │ char_s │ ╭───┬───────╮ │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ 0 │ emacs │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ 1 │ vi_no │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ rmal │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ 2 │ vi_in │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ sert │ │ s} │ │ │",
"│ │ │ │ │ │ │ │ │ ╰───┴───────╯ │ │ │ │",
"│ │ │ │ ╰────┴───────────────────────────┴──────────┴─────────┴───────────────┴─────╯ │ │",
"│ │ ╰──────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────╯ │",
@ -1611,6 +1750,8 @@ fn table_expande_with_no_header_internally_1() {
let actual = nu!(format!("{} | table --expand --width 136", nu_value.trim()));
_print_lines(&actual.out, 136);
assert_eq!(
actual.out,
join_lines([
@ -1777,37 +1918,87 @@ fn table_expande_with_no_header_internally_1() {
"│ │ │ │ │ │ ╰─────┴──────────╯ │ │ │",
"│ │ │ │ │ display_output │ │ │ │",
"│ │ │ │ ╰────────────────┴────────────────────╯ │ │",
"│ │ │ │ ╭───┬───────────────────────────┬────────────────────────┬─────╮ │ │",
"│ │ │ menus │ │ # │ name │ only_buffer_difference │ ... │ │ │",
"│ │ │ │ ├───┼───────────────────────────┼────────────────────────┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ false │ ... │ │ │",
"│ │ │ │ │ 1 │ history_menu │ true │ ... │ │ │",
"│ │ │ │ │ 2 │ help_menu │ true │ ... │ │ │",
"│ │ │ │ │ 3 │ commands_menu │ false │ ... │ │ │",
"│ │ │ │ │ 4 │ vars_menu │ true │ ... │ │ │",
"│ │ │ │ │ 5 │ commands_with_description │ true │ ... │ │ │",
"│ │ │ │ ╰───┴───────────────────────────┴────────────────────────┴─────╯ │ │",
"│ │ │ │ ╭───┬───────────────────────────┬────────────────────────┬───────┬─────╮ │ │",
"│ │ │ menus │ │ # │ name │ only_buffer_difference │ marke │ ... │ │ │",
"│ │ │ │ │ │ │ │ r │ │ │ │",
"│ │ │ │ ├───┼───────────────────────────┼────────────────────────┼───────┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ false │ | │ ... │ │ │",
"│ │ │ │ │ 1 │ history_menu │ true │ ? │ ... │ │ │",
"│ │ │ │ │ 2 │ help_menu │ true │ ? │ ... │ │ │",
"│ │ │ │ │ 3 │ commands_menu │ false │ # │ ... │ │ │",
"│ │ │ │ │ 4 │ vars_menu │ true │ # │ ... │ │ │",
"│ │ │ │ │ 5 │ commands_with_description │ true │ # │ ... │ │ │",
"│ │ │ │ ╰───┴───────────────────────────┴────────────────────────┴───────┴─────╯ │ │",
"│ │ │ │ ╭────┬───────────────────────────┬──────────┬─────────┬──────────┬─────╮ │ │",
"│ │ │ keybindings │ │ # │ name │ modifier │ keycode │ mode │ ... │ │ │",
"│ │ │ keybindings │ │ # │ name │ modifier │ keycode │ mode │ eve │ │ │",
"│ │ │ │ │ │ │ │ │ │ nt │ │ │",
"│ │ │ │ ├────┼───────────────────────────┼──────────┼─────────┼──────────┼─────┤ │ │",
"│ │ │ │ │ 0 │ completion_menu │ none │ tab │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 1 │ completion_previous │ shift │ backtab │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 2 │ history_menu │ control │ char_r │ emacs │ ... │ │ │",
"│ │ │ │ │ 3 │ next_page │ control │ char_x │ emacs │ ... │ │ │",
"│ │ │ │ │ 4 │ undo_or_previous_page │ control │ char_z │ emacs │ ... │ │ │",
"│ │ │ │ │ 5 │ yank │ control │ char_y │ emacs │ ... │ │ │",
"│ │ │ │ │ 6 │ unix-line-discard │ control │ char_u │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 7 │ kill-line │ control │ char_k │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 8 │ commands_menu │ control │ char_t │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 9 │ vars_menu │ alt │ char_o │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 10 │ commands_with_description │ control │ char_s │ [list 3 │ ... │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ │ │ │",
"│ │ │ │ │ 0 │ completion_menu │ none │ tab │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 1 │ completion_previous │ shift │ backtab │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 2 │ history_menu │ control │ char_r │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ s} │ │ │",
"│ │ │ │ │ 3 │ next_page │ control │ char_x │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 4 │ undo_or_previous_page │ control │ char_z │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 5 │ yank │ control │ char_y │ emacs │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 6 │ unix-line-discard │ control │ char_u │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 7 │ kill-line │ control │ char_k │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 1 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ } │ │ │",
"│ │ │ │ │ 8 │ commands_menu │ control │ char_t │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ s} │ │ │",
"│ │ │ │ │ 9 │ vars_menu │ alt │ char_o │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ s} │ │ │",
"│ │ │ │ │ 10 │ commands_with_description │ control │ char_s │ [list 3 │ {re │ │ │",
"│ │ │ │ │ │ │ │ │ items] │ cor │ │ │",
"│ │ │ │ │ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ │ │ │ │ eld │ │ │",
"│ │ │ │ │ │ │ │ │ │ s} │ │ │",
"│ │ │ │ ╰────┴───────────────────────────┴──────────┴─────────┴──────────┴─────╯ │ │",
"│ │ ╰──────────────────────────────────┴──────────────────────────────────────────────────────────────────────────╯ │",
"╰────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
@ -2521,6 +2712,7 @@ fn table_theme_on_border_with_love() {
fn table_theme_on_border_thin() {
assert_eq!(
create_theme_output("thin"),
// ["┌─#─┬a_looooooong_name┬─b─┬─c─┐│ 0 │ 1 │ 2 │ 3 │└─#─┴a_looooooong_name┴─b─┴─c─┘"]
[
"┌─#─┬─a─┬─b─┬───────c────────┐│ 0 │ 1 │ 2 │ 3 │├───┼───┼───┼────────────────┤│ 1 │ 4 │ 5 │ [list 3 items] │└───┴───┴───┴────────────────┘",
"┌─#─┬─a─┬─b─┬───────c────────┐│ 0 │ 1 │ 2 │ 3 │├───┼───┼───┼────────────────┤│ 1 │ 4 │ 5 │ [list 3 items] │└─#─┴─a─┴─b─┴───────c────────┘",
@ -3149,3 +3341,21 @@ fn table_index_expand() {
"
);
}
#[test]
fn table_expand_big_header() {
let actual = nu!("
let column_name = (('' | fill -c 'a' --width 81))
[{ $column_name: 'contents' }] | table -e --width=80
");
assert_eq!(
actual.out,
"╭───┬──────────────────────────────────────────────────────────────────────────╮\
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaa \
\
0 contents \
"
);
}

File diff suppressed because it is too large Load Diff

View File

@ -240,7 +240,7 @@ fn expand_list(input: &[Value], cfg: Cfg<'_>) -> TableResult {
}
let mut available = available_width - pad_space;
let mut column_width = string_width(&header);
let mut column_width = 0;
if !is_last_column {
// we need to make sure that we have a space for a next column if we use available width
@ -293,9 +293,18 @@ fn expand_list(input: &[Value], cfg: Cfg<'_>) -> TableResult {
column_rows = column_rows.saturating_add(cell.size);
}
let mut head_width = string_width(&header);
let mut header = header;
if head_width > available {
header = wrap_text(&header, available, cfg.opts.config);
head_width = available;
}
let head_cell = NuRecordsValue::new(header);
data[0].push(head_cell);
column_width = max(column_width, head_width);
if column_width > available {
// remove the column we just inserted
for row in &mut data {

View File

@ -31,6 +31,27 @@ pub fn string_wrap(text: &str, width: usize, keep_words: bool) -> String {
Wrap::wrap(text, width, keep_words)
}
pub fn string_expand(text: &str, width: usize) -> String {
use std::{borrow::Cow, iter::repeat};
use tabled::grid::util::string::{get_line_width, get_lines};
get_lines(text)
.map(|line| {
let length = get_line_width(&line);
if length < width {
let mut line = line.into_owned();
let remain = width - length;
line.extend(repeat(' ').take(remain));
Cow::Owned(line)
} else {
line
}
})
.collect::<Vec<_>>()
.join("\n")
}
pub fn string_truncate(text: &str, width: usize) -> String {
let line = match text.lines().next() {
Some(line) => line,

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
[files]
extend-exclude = [
".git/",
"crates/nu-command/tests/commands/table.rs",
"crates/nu-cmd-extra/assets/228_themes.json",
"tests/fixtures/formats/",
]