From 2b4c54d383014509fa2271fa40bf2c1656707b7f Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Sun, 5 Jan 2025 17:01:05 -0500 Subject: [PATCH] Add newline to empty list output (#14758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Adds a newline to the empty list output. Fixes #14748. This does not affect the `[empty list]` text output in the REPL, just the `print` output (to be honest, I'm not certain why, but I'm guessing the REPL was adding an extra newline somewhere to compensate). The `bytes.push('\n')` replicates the code from the below `convert_table_to_output` function, which is bypassed for empty lists. Before: ```nushell [] # => ╭────────────╮ # => │ empty list │ # => ╰────────────╯ print ([]) text # => ╭────────────╮ # => │ empty list │ # => ╰────────────╯text ``` After: ```nushell [] # => ╭────────────╮ # => │ empty list │ # => ╰────────────╯ print ([]) text # => ╭────────────╮ # => │ empty list │ # => ╰────────────╯ # => text ``` # User-Facing Changes * Fixes "empty list" placeholder text output when using the `print` command # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting N/A --- crates/nu-command/src/viewers/table.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index c2c3af524f..925ffbc5eb 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -885,7 +885,9 @@ impl Iterator for PagingTableCreator { &self.engine_state, &self.stack, ); - Some(Ok(result.into_bytes())) + let mut bytes = result.into_bytes(); + bytes.push(b'\n'); + Some(Ok(bytes)) } else { None };