From 30e86ac939e8b0de7cd8abb5d453772ab2febc8d Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 10 Mar 2025 13:32:13 -0700 Subject: [PATCH] Add a "secondary" meta key to GPUI keystroke parsing (#26390) "secondary" means "cmd" on macOS and "ctrl" on not macOS. Release Notes: - Added a "secondary" meta key to the zed keystroke parser, which maps to 'cmd' on macOS and 'ctrl' off of macOS --- crates/gpui/src/platform/keystroke.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/keystroke.rs b/crates/gpui/src/platform/keystroke.rs index a81f63c7f2c92f3a5c636de4d3fc8195d2ed556c..4af8706ae04cede59a82540b0096bbeaf8f8f723 100644 --- a/crates/gpui/src/platform/keystroke.rs +++ b/crates/gpui/src/platform/keystroke.rs @@ -76,8 +76,9 @@ impl Keystroke { } /// key syntax is: - /// [ctrl-][alt-][shift-][cmd-][fn-]key[->key_char] + /// [secondary-][ctrl-][alt-][shift-][cmd-][fn-]key[->key_char] /// key_char syntax is only used for generating test events, + /// secondary means "cmd" on macOS and "ctrl" on other platforms /// when matching a key with an key_char set will be matched without it. pub fn parse(source: &str) -> std::result::Result { let mut control = false; @@ -95,6 +96,13 @@ impl Keystroke { "alt" => alt = true, "shift" => shift = true, "fn" => function = true, + "secondary" => { + if cfg!(target_os = "macos") { + platform = true + } else { + control = true + }; + } "cmd" | "super" | "win" => platform = true, _ => { if let Some(next) = components.peek() {