From cd4511c548242c987d4a8e00985243d16807dcef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 28 Oct 2026 08:07:19 -0700 Subject: [PATCH] Keyboard Shortcuts: an empty saved shortcut does not list a command that needs a value A command that needs a value stayed listed when a saved or imported set held an empty shortcut for it, showing no key. It is now listed only while its saved shortcut is not empty. --- crates/ui-egui/src/shortcut_editor.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 8901934a8..2fa55f74e 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -336,9 +336,9 @@ fn runs_without_params(params: &str) -> bool { } /// Does the editor list `e` under `overrides`? An entry that [`needs_a_value`] is listed only while -/// the user has changed its shortcut. +/// the user has given it a shortcut. fn listed(overrides: &Overrides, e: &Entry) -> bool { - !needs_a_value(&e.key) || crate::keymap::has_override(overrides, &e.key) + !needs_a_value(&e.key) || overrides.get(&crate::keymap::stored_key(&e.key)).is_some_and(|t| !t.is_empty()) } /// Is `key` a command with a menu path and no default shortcut that a key press can't run: no @@ -1241,6 +1241,10 @@ mod tests { (Some("document.setUnits"), Some("Cmd+Alt+Shift+F12"), Some(true)) ); assert!(menu_rows(&mut app, "units").iter().any(|r| r == "File › Document Setup › Units")); + // An empty saved shortcut (as an imported set can hold) gives it no key, so it is not listed. + crate::keymap::set_override(&mut app.ui.shortcut_overrides, "document.setUnits", ""); + let list = run_command(&mut app, "shortcuts.list", &json!({"query": "document.setUnits"})).unwrap().unwrap(); + assert_eq!(list, json!([])); // Every entry with a default shortcut is listed, and so are commands a key press runs: one // whose params are all optional, one the menu bar runs without params (Rotate… opens its // dialog) and one that opens a dialog for its values (New Variable).