From 53fbf624934916a9527737305d410794d1472a48 Mon Sep 17 00:00:00 2001 From: Devyn Cairns Date: Fri, 26 Jul 2024 01:03:05 -0700 Subject: [PATCH] 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. --- crates/nu-cli/src/commands/keybindings_list.rs | 4 +++- crates/nu-cli/tests/commands/keybindings_list.rs | 7 +++++++ crates/nu-cli/tests/commands/mod.rs | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 crates/nu-cli/tests/commands/keybindings_list.rs diff --git a/crates/nu-cli/src/commands/keybindings_list.rs b/crates/nu-cli/src/commands/keybindings_list.rs index 350df7b820..abb5909a97 100644 --- a/crates/nu-cli/src/commands/keybindings_list.rs +++ b/crates/nu-cli/src/commands/keybindings_list.rs @@ -61,10 +61,12 @@ impl Command for KeybindingsList { .map(|option| call.has_flag(engine_state, stack, option)) .collect::, 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(); diff --git a/crates/nu-cli/tests/commands/keybindings_list.rs b/crates/nu-cli/tests/commands/keybindings_list.rs new file mode 100644 index 0000000000..4ab9f3bacf --- /dev/null +++ b/crates/nu-cli/tests/commands/keybindings_list.rs @@ -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"); +} diff --git a/crates/nu-cli/tests/commands/mod.rs b/crates/nu-cli/tests/commands/mod.rs index 00488f0b9e..087791302e 100644 --- a/crates/nu-cli/tests/commands/mod.rs +++ b/crates/nu-cli/tests/commands/mod.rs @@ -1 +1,2 @@ +mod keybindings_list; mod nu_highlight;