From 7ee6d91ba0549d33d09c644a4ef142747b51f3a3 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 3 Mar 2025 10:13:37 +0100 Subject: [PATCH] Work around keyboard-layout related bugs in WezTerm's modifyOtherKeys modifyOtherKeys with non-English or other non-default keyboard layouts will cause wrong keys to be sent by WezTerm. Let's try to disable it for now. Proposed upstream fix: https://github.com/wezterm/wezterm/pull/6748 Closes #11204 --- src/input_common.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/input_common.rs b/src/input_common.rs index 879d082d8..0ed2570a2 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -437,6 +437,7 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) { static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_JETBRAINS: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_KITTY: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +static IN_WEZTERM: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocol_hacks() { use std::env::var_os; @@ -457,6 +458,10 @@ pub fn terminal_protocol_hacks() { ); IN_KITTY .store(var_os("TERM").is_some_and(|term| term.as_os_str().as_bytes() == b"xterm-kitty")); + IN_WEZTERM.store( + var_os("TERM_PROGRAM") + .is_some_and(|term_program| term_program.as_os_str().as_bytes() == b"WezTerm"), + ); } fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> { @@ -491,7 +496,7 @@ pub fn terminal_protocols_enable_ifn() { // Jetbrains IDE terminals vomit CSI u // iTerm fails to option-modify keys concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b=",) - } else if IN_KITTY.load() { + } else if IN_KITTY.load() || IN_WEZTERM.load() { // Kitty spams the log for modifyotherkeys concat!( "\x1b[?2004h", // Bracketed paste @@ -524,7 +529,7 @@ pub(crate) fn terminal_protocols_disable_ifn() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) } else if IN_JETBRAINS.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) - } else if IN_KITTY.load() { + } else if IN_KITTY.load() || IN_WEZTERM.load() { // Kitty spams the log for modifyotherkeys concat!( "\x1b[?2004l", // Bracketed paste