From 9ed2ca792fc011ba8aeff1bd7473a00cad83da3c Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Mon, 6 Jan 2025 16:34:09 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20extra=20newline=20on=20empty=20lists=20wh?= =?UTF-8?q?en=20$env.config.table.show=5Fempty=20is=E2=80=A6=20(#14766)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description I just noticed that #14758 adds an extra newline when `$env.config.table.show_empty = false`. This PR makes sure the placeholder text is non-empty before adding the newline. Before #14758: ```nushell $env.config.table.show_empty = false print ([]) text # => text echo [] ``` Before PR: ```nushell $env.config.table.show_empty = false print ([]) text # => # => text echo [] # => ``` After PR: ```nushell $env.config.table.show_empty = false print ([]) text # => text echo [] ``` # User-Facing Changes None, fix to #14758 which has not been included in a release # 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 925ffbc5eb..9ee74e3ed6 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -886,7 +886,10 @@ impl Iterator for PagingTableCreator { &self.stack, ); let mut bytes = result.into_bytes(); - bytes.push(b'\n'); + // Add extra newline if show_empty is enabled + if !bytes.is_empty() { + bytes.push(b'\n'); + } Some(Ok(bytes)) } else { None