Skip to content

Commit df5230f

Browse files
committed
Reliably disable modifyOtherKeys on WezTerm
WezTerm allows applications to enable modifyOtherKeys by default. Its implementation has issues on non-English or non-QWERTY layouts, see wezterm/wezterm#6087 and fish-shell#11204. fish 4.0.1 disabled modifyOtherKeys on WezTerm specifically (7ee6d91 (Work around keyboard-layout related bugs in WezTerm's modifyOtherKeys, 2025-03-03)), fish 4.1.0 didn't, because at that time, WezTerm would advertise support for the kitty keyboard protocol (even if applications are not allowed to enable it) which would make fish skip requesting the legacy modifyOtherKeys. WezTerm no longer advertises that if config.enable_kitty_keyboard is false. Let's work around it in another way.
1 parent 7cd0943 commit df5230f

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ fish 4.1.1 (released ???)
77
This release fixes the following regressions identified in 4.1.0:
88

99
- Some :doc:`fish_config <cmds/fish_config>` subcommands for prompts and themes were broken in standalone Linux builds (those using the ``embed-data`` cargo feature), which has been fixed (:issue:`11832`).
10+
- Our new workaround for WezTerm's `issues with modifyOtherKeys <https://github.com/wezterm/wezterm/issues/6087>`__ breaking shifted keys was broken on some versions of WezTerm, which has been fixed (:issue:`11204`).
1011

1112
fish 4.1.0 (released September 27, 2025)
1213
========================================

src/tty_handoff.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub enum TtyQuirks {
6464
PreKittyIterm2,
6565
// Whether we are running under tmux.
6666
Tmux,
67+
// Whether we are running under WezTerm.
68+
Wezterm,
6769
}
6870

6971
impl TtyQuirks {
@@ -74,6 +76,8 @@ impl TtyQuirks {
7476
PreKittyIterm2
7577
} else if xtversion.starts_with(L!("tmux ")) {
7678
Tmux
79+
} else if xtversion.starts_with(L!("WezTerm ")) {
80+
Wezterm
7781
} else {
7882
None
7983
}
@@ -85,7 +89,8 @@ impl TtyQuirks {
8589
enum ProtocolKind {
8690
KittyKeyboard, // Kitty keyboard support, producing CSI-u style encoding.
8791
Other, // Other protocols (e.g., modifyOtherKeys)
88-
None, // No protocols
92+
WorkAroundWezTerm,
93+
None, // No protocols
8994
}
9095

9196
// Commands to emit to enable or disable TTY protocols. Each of these contains
@@ -95,6 +100,7 @@ enum ProtocolKind {
95100
struct ProtocolBytes {
96101
kitty_keyboard: Box<[u8]>,
97102
other: Box<[u8]>,
103+
wezterm_workaround: Box<[u8]>,
98104
none: Box<[u8]>,
99105
}
100106

@@ -123,6 +129,7 @@ impl TtyProtocolsSet {
123129
match protocol {
124130
ProtocolKind::KittyKeyboard => &cmds.kitty_keyboard,
125131
ProtocolKind::Other => &cmds.other,
132+
ProtocolKind::WorkAroundWezTerm => &cmds.wezterm_workaround,
126133
ProtocolKind::None => &cmds.none,
127134
}
128135
}
@@ -141,13 +148,19 @@ impl TtyQuirks {
141148
// Determine which keyboard protocol.
142149
// This is used from a signal handler.
143150
fn safe_get_supported_protocol(&self) -> ProtocolKind {
144-
use TtyQuirks::PreKittyIterm2;
151+
use TtyQuirks::{PreKittyIterm2, Wezterm};
145152
if *self == PreKittyIterm2 {
146153
return ProtocolKind::Other;
147154
}
148155
match KITTY_KEYBOARD_SUPPORTED.get() {
149156
Some(&true) => ProtocolKind::KittyKeyboard,
150-
Some(&false) => ProtocolKind::Other,
157+
Some(&false) => {
158+
if *self == Wezterm {
159+
ProtocolKind::WorkAroundWezTerm
160+
} else {
161+
ProtocolKind::Other
162+
}
163+
}
151164
None => ProtocolKind::None,
152165
}
153166
}
@@ -178,6 +191,10 @@ impl TtyQuirks {
178191
ModifyOtherKeysEnable, // XTerm's modifyOtherKeys
179192
ApplicationKeypadModeEnable, // set application keypad mode, so the keypad keys send unique codes
180193
])),
194+
wezterm_workaround: serialize_commands(maybe_enable_focus_reporting(&[
195+
DecsetBracketedPaste,
196+
ApplicationKeypadModeEnable, // set application keypad mode, so the keypad keys send unique codes
197+
])),
181198
none: serialize_commands(maybe_enable_focus_reporting(&[DecsetBracketedPaste])),
182199
};
183200
let disablers = ProtocolBytes {
@@ -190,6 +207,10 @@ impl TtyQuirks {
190207
ModifyOtherKeysDisable,
191208
ApplicationKeypadModeDisable,
192209
])),
210+
wezterm_workaround: serialize_commands(maybe_disable_focus_reporting(&[
211+
DecrstBracketedPaste,
212+
ApplicationKeypadModeDisable,
213+
])),
193214
none: serialize_commands(maybe_disable_focus_reporting(&[DecrstBracketedPaste])),
194215
};
195216
TtyProtocolsSet {
@@ -273,6 +294,7 @@ fn set_tty_protocols_active(on_write: fn(), enable: bool) -> bool {
273294
match protocols.quirks.safe_get_supported_protocol() {
274295
ProtocolKind::KittyKeyboard => FLOG!(reader, mode, "kitty keyboard protocol"),
275296
ProtocolKind::Other => FLOG!(reader, mode, "other extended keys"),
297+
ProtocolKind::WorkAroundWezTerm => FLOG!(reader, mode, "wezterm; no modifyOtherKeys"),
276298
ProtocolKind::None => (),
277299
};
278300
(on_write)();

0 commit comments

Comments
 (0)