Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display empty records and lists #7925

Merged
merged 14 commits into from Feb 22, 2023

Conversation

NotLebedev
Copy link
Contributor

@NotLebedev NotLebedev commented Jan 31, 2023

Description

Fix some issues related to #7444

  1. Empty lists and records are now displayed as a small notice in a box:
    image
    image
  2. Empty records are now correctly displayed if inside of another record list or table:
    image
    image
  3. Fixed inconsistent coloring of empty list placeholder inside of lists/tables:
    image
    image

User-Facing Changes

table command now displays empty records and lists like a table with text and correctly displays empty records inside tables and lists.

New behavior of displaying empty lists and records can be disabled using table.show_empty config option.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@NotLebedev
Copy link
Contributor Author

Spotted an issue. Commands like mkdir and rm that have a --verbose option return empty list even when called without --verbose
image
image
Not sure what to do with this

@NotLebedev NotLebedev changed the title Empty table placeholder Display empty records and lists Jan 31, 2023
@rgwood
Copy link
Contributor

rgwood commented Feb 7, 2023

Thank you; this looks like a really good improvement!

For mkdir and rm... yeah, those commands are a bit of a mess, I don't like how they return info as a list<string> instead of printing to stderr.

It would be a breaking change, but maybe we should finally change those to return nothing and print to stderr?

@rgwood
Copy link
Contributor

rgwood commented Feb 7, 2023

I asked on Discord and other people agree that we should change the filesystem commands to return nothing and print info to stderr: https://discord.com/channels/601130461678272522/615329862395101194/1072523941865857055

Would you be up for making that change (either as part of this PR or in another PR)? Sorry that this is turning into a bit of a yak shave 😭

@NotLebedev
Copy link
Contributor Author

Yes, I can do this. I will make a separate PR. It will be easier to work for me that way

rgwood pushed a commit that referenced this pull request Feb 9, 2023
# Description

Makes `mkdir`, `cp`, `mv` and `rm` return nothing and print info to
stderr:

![image](https://user-images.githubusercontent.com/17511668/217859228-feffa4bc-c22d-45d3-b330-1903f5a4d938.png)
See #7925 (comment)
and
[discord](https://discord.com/channels/601130461678272522/615329862395101194/1072523941865857055).

# User-Facing Changes

`mkdir`, `cp`, `mv` and `rm` will return nothing and print info to
stderr with `--verbose` flag.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
@NotLebedev
Copy link
Contributor Author

NotLebedev commented Feb 10, 2023

I think a useful addition might be a config option and table command option to switch to old behavior of not displaying this box
image
I think adding config.table.show_empty option and table --no-empty-placeholder should be useful. This should only control this boxes. This `[list 0 items] will be displayed always
image
Also, if this option is added, should it be on or off by default?

@rgwood
Copy link
Contributor

rgwood commented Feb 10, 2023

Also, if this option is added, should it be on or off by default?

I vote for on by default. I don't think it needs to be configurable, but I'm OK with a config option if you want one.

@NotLebedev
Copy link
Contributor Author

I vote for on by default. I don't think it needs to be configurable, but I'm OK with a config option if you want one.

I already did it this way. This PR is ready for review if somebody got time.

@rgwood
Copy link
Contributor

rgwood commented Feb 15, 2023

Cool!

I haven't had time to do a full code review yet, but I'll try to get to it soon. We discussed this PR in the weekly team meeting, and we agreed that we like the change. It's probably going to break a few things, so the plan is to merge it shortly after the next release (which is on Feb 21) - that will give us more time to test it in main.

Copy link
Contributor

@rgwood rgwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the PR!

Looking forward to merging this after the upcoming release.

@fdncred
Copy link
Collaborator

fdncred commented Feb 22, 2023

@NotLebedev would you mind fixing these conflicts so we can merge this pr? Thanks!

@fdncred
Copy link
Collaborator

fdncred commented Feb 22, 2023

I'm wondering if this change is breaking our table tests or just if another merge main is needed since I just landed another table thing?

@NotLebedev
Copy link
Contributor Author

It broke a test. There were missing {record 0 fields} in expected table output

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #7925 (85087e4) into main (8608d8d) will decrease coverage by 0.07%.
The diff coverage is 27.18%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7925      +/-   ##
==========================================
- Coverage   54.28%   54.21%   -0.07%     
==========================================
  Files         608      608              
  Lines       98949    99138     +189     
==========================================
+ Hits        53713    53748      +35     
- Misses      45236    45390     +154     
Impacted Files Coverage Δ
crates/nu-command/src/viewers/table.rs 31.18% <25.42%> (-0.01%) ⬇️
crates/nu-protocol/src/ty.rs 72.85% <28.00%> (-11.50%) ⬇️
crates/nu-color-config/src/style_computer.rs 80.76% <100.00%> (ø)
crates/nu-protocol/src/config.rs 38.01% <100.00%> (+0.17%) ⬆️
crates/nu-table/src/nu_protocol_table.rs 0.00% <0.00%> (ø)

@fdncred fdncred added this pull request to the merge queue Feb 22, 2023
@fdncred
Copy link
Collaborator

fdncred commented Feb 22, 2023

Let's try it out.

Merged via the queue into nushell:main with commit e389e51 Feb 22, 2023
@rgwood
Copy link
Contributor

rgwood commented Mar 5, 2023

Following up on the discussion in #8014 (comment)

How are we feeling about this one? We're 9 days from the release and it seems like we're still running into related issues. I'm wondering if we should temporarily disable this feature to give us more time to polish it.

It feels like this PR has led to several others like #8292 and I don't think we're in a place where we can confidently explain to users "here's what we changed, and here's why it's better" yet.

@NotLebedev
Copy link
Contributor Author

Following up on the discussion in #8014 (comment)

How are we feeling about this one? We're 9 days from the release and it seems like we're still running into related issues. I'm wondering if we should temporarily disable this feature to give us more time to polish it.

It feels like this PR has led to several others like #8292 and I don't think we're in a place where we can confidently explain to users "here's what we changed, and here's why it's better" yet.

I agree. This and related changes are a bit raw currently. #8292 is sure to cause some more trouble and may bring up some more changes.

This one can be removed from release entirely or disabled by default for this release via table.show_empty config option.

@sholderbach sholderbach added the pr:breaking-change This PR implies a change affecting users and has to be noted in the release notes label Mar 5, 2023
@rgwood
Copy link
Contributor

rgwood commented Mar 7, 2023

@NotLebedev Do you have time to submit a PR to disable this? If not I'll get around to it later today or tomorrow.

@NotLebedev
Copy link
Contributor Author

@NotLebedev Do you have time to submit a PR to disable this? If not I'll get around to it later today or tomorrow.

Can do. Are we disabling it by default or what should I do?

@rgwood
Copy link
Contributor

rgwood commented Mar 7, 2023

I don't know what the best thing to do is (haven't had time to think about this much).

@hustcer
Copy link
Contributor

hustcer commented Mar 8, 2023

To me, the most important thing currently is to make sure [1 2 3] | each {|e| print $e } don't display empty list

@NotLebedev NotLebedev mentioned this pull request Mar 8, 2023
sophiajt pushed a commit that referenced this pull request Mar 8, 2023
# Description

Hides #7925 from config and
disables by default. Option is still present in config, just hidden.

# User-Facing Changes

Users can no longer find `table.show_empty` in config and it is set to
false by default.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
@hustcer hustcer modified the milestone: v0.77.0 Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:breaking-change This PR implies a change affecting users and has to be noted in the release notes wait-until-after-nushell-release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants