mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-30 04:37:29 -06:00
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.
This commit is contained in:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user