From 7c5766137bd2e962cc8b3edaaa698732cb779828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 10 Jul 2026 12:11:06 -0400 Subject: [PATCH] fix(shortcuts): bind only the current platform's keys --- crates/ely_app/src/shortcuts.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/ely_app/src/shortcuts.rs b/crates/ely_app/src/shortcuts.rs index 3f0f9af..57e36c5 100644 --- a/crates/ely_app/src/shortcuts.rs +++ b/crates/ely_app/src/shortcuts.rs @@ -244,8 +244,20 @@ const fn shortcut( ShortcutBinding { action, platform, keystroke } } +/// Only the current platform's keys may reach GPUI: registering the other +/// platform's `ctrl-*` set on macOS hijacks readline editing inside every +/// text input (and `cmd-*` is meaningless elsewhere). +fn platform_bindings() -> impl Iterator { + let platform = if cfg!(target_os = "macos") { + ShortcutPlatform::Macos + } else { + ShortcutPlatform::WindowsLinux + }; + SHORTCUT_BINDINGS.iter().filter(move |binding| binding.platform == platform) +} + pub(crate) fn bind_shortcuts(cx: &mut App) { - cx.bind_keys(SHORTCUT_BINDINGS.iter().map(|binding| binding.key_binding())); + cx.bind_keys(platform_bindings().map(|binding| binding.key_binding())); } impl ShortcutBinding { @@ -356,6 +368,18 @@ mod tests { } } + #[test] + fn bound_shortcuts_are_scoped_to_the_current_platform() { + let expected = if cfg!(target_os = "macos") { + ShortcutPlatform::Macos + } else { + ShortcutPlatform::WindowsLinux + }; + + assert!(super::platform_bindings().next().is_some()); + assert!(super::platform_bindings().all(|binding| binding.platform == expected)); + } + fn platform_labels(action: ShortcutAction) -> Vec { let profile = ShortcutProfile::default_profile(); [ShortcutPlatform::Macos, ShortcutPlatform::WindowsLinux]