Fix keybindings list being empty by default (#13456)

# Description

Made a mistake when fixing this for IR. The default behavior with no
options set is to list everything. Restored that.

This should go in the 0.96.1 patch release.

# Tests + Formatting
Added regression test.
This commit is contained in:
Devyn Cairns 2024-07-26 01:03:05 -07:00 committed by GitHub
parent e68f744dda
commit 53fbf62493
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View file

@ -61,10 +61,12 @@ impl Command for KeybindingsList {
.map(|option| call.has_flag(engine_state, stack, option))
.collect::<Result<Vec<_>, ShellError>>()?;
let no_option_specified = presence.iter().all(|present| !*present);
let records = all_options
.iter()
.zip(presence)
.filter(|(_, present)| *present)
.filter(|(_, present)| no_option_specified || *present)
.flat_map(|(option, _)| get_records(option, call.head))
.collect();

View file

@ -0,0 +1,7 @@
use nu_test_support::nu;
#[test]
fn not_empty() {
let result = nu!("keybindings list | is-not-empty");
assert_eq!(result.out, "true");
}

View file

@ -1 +1,2 @@
mod keybindings_list;
mod nu_highlight;