From aaf2f9d309195e207845a7b2b486a8edf69570a8 Mon Sep 17 00:00:00 2001 From: John Tur Date: Mon, 10 Nov 2025 15:11:18 -0500 Subject: [PATCH] Ignore "Option as Meta" setting outside of macOS (#42367) The "Option" key only exists on a Mac. On other operating systems, it is always expected that the Alt key generates escaped characters. Fixes https://github.com/zed-industries/zed/issues/40583 Release Notes: - N/A --- crates/terminal/src/mappings/keys.rs | 4 ++-- crates/terminal/src/terminal.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/terminal/src/mappings/keys.rs b/crates/terminal/src/mappings/keys.rs index b003bf82ad368cd9938788b26a037895677f2caa..8073961fc5451728c23582f5eee21495ee002e63 100644 --- a/crates/terminal/src/mappings/keys.rs +++ b/crates/terminal/src/mappings/keys.rs @@ -46,7 +46,7 @@ impl AlacModifiers { pub fn to_esc_str( keystroke: &Keystroke, mode: &TermMode, - alt_is_meta: bool, + option_as_meta: bool, ) -> Option> { let modifiers = AlacModifiers::new(keystroke); @@ -218,7 +218,7 @@ pub fn to_esc_str( } } - if alt_is_meta { + if !cfg!(target_os = "macos") || option_as_meta { let is_alt_lowercase_ascii = modifiers == AlacModifiers::Alt && keystroke.key.is_ascii(); let is_alt_uppercase_ascii = keystroke.modifiers.alt && keystroke.modifiers.shift && keystroke.key.is_ascii(); diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 8283f5fad77ff3b6a4020db06439714d38bf119b..4f6f0e75ee6f38615a2d82d7a4ad3ee0c06c2323 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -1490,14 +1490,14 @@ impl Terminal { } } - pub fn try_keystroke(&mut self, keystroke: &Keystroke, alt_is_meta: bool) -> bool { + pub fn try_keystroke(&mut self, keystroke: &Keystroke, option_as_meta: bool) -> bool { if self.vi_mode_enabled { self.vi_motion(keystroke); return true; } // Keep default terminal behavior - let esc = to_esc_str(keystroke, &self.last_content.mode, alt_is_meta); + let esc = to_esc_str(keystroke, &self.last_content.mode, option_as_meta); if let Some(esc) = esc { match esc { Cow::Borrowed(string) => self.input(string.as_bytes()),