nushell/crates/nu-command/src
132ikl 2b4c54d383
Add newline to empty list output (#14758)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

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
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

* Fixes "empty list" placeholder text output when using the `print`
command

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
N/A
2025-01-05 16:01:05 -06:00
..
bytes Add bytes split command (#14652) 2024-12-25 07:04:43 -06:00
charting Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
conversions Use Value::coerce_bool in into bool (#14731) 2025-01-03 08:11:34 -06:00
database Remove usages of internal_span (#14700) 2024-12-30 16:47:06 +08:00
date Deprecate date to-record and date to-table (#14319) 2024-11-29 23:06:26 +01:00
debug Bump tabled to 0.17 (#14415) 2024-12-28 08:19:48 -06:00
env Fix config reset to use scaffold config files (#14756) 2025-01-05 16:18:19 -05:00
experimental Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
filesystem Make utouch the new touch (#14721) 2025-01-02 06:26:46 -06:00
filters Make get const (#14751) 2025-01-04 16:41:03 -05:00
formats Switch from serde_yaml to serde_yml (#14630) 2024-12-25 21:35:49 +08:00
generators Seq char update will work on all char (#14261) 2024-11-15 21:05:29 +01:00
hash add binary as input to hash commands (#13923) 2024-09-25 16:47:52 +08:00
help replace regex crate with fancy_regex (#14646) 2025-01-01 17:37:50 -06:00
math better error message for "sum", "product", and "sum_of_squares" (#14711) 2024-12-31 16:04:23 -06:00
misc Add environment variables for sourced files (#14486) 2024-12-02 06:19:20 -06:00
network Remove usages of internal_span (#14700) 2024-12-30 16:47:06 +08:00
path Add path self command for getting absolute paths to files at parse time (#14303) 2024-12-06 08:19:08 -06:00
platform Remove usages of internal_span (#14700) 2024-12-30 16:47:06 +08:00
random Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
removed Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
shells Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
stor Reference the correct command: insert -> delete (#14696) 2024-12-29 14:05:12 -06:00
strings replace regex crate with fancy_regex (#14646) 2025-01-01 17:37:50 -06:00
system Create nu_glob::is_glob function (#14717) 2025-01-01 19:04:17 -05:00
viewers Add newline to empty list output (#14758) 2025-01-05 16:01:05 -06:00
default_context.rs Make utouch the new touch (#14721) 2025-01-02 06:26:46 -06:00
example_test.rs Overhaul $in expressions (#13357) 2024-07-17 16:02:42 -05:00
lib.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
progress_bar.rs Cut down unnecessary lint allows (#14335) 2024-11-15 19:24:39 +01:00
sort_utils.rs Rework sorting and add cell path and closure comparators to sort-by (#13154) 2024-10-09 19:18:16 -07:00