fix: avoid ctrl-tab escape sequences in legacy panes

refs #2296
This commit is contained in:
Ogulcan Celik 2026-08-06 01:42:48 +03:00
parent 8b7cd9f067
commit ea047db8e4
1 changed files with 31 additions and 0 deletions

View File

@ -1711,6 +1711,13 @@ impl GhosttyPaneTerminal {
key: crate::input::TerminalKey,
protocol: crate::input::KeyboardProtocol,
) -> Vec<u8> {
if matches!(protocol, crate::input::KeyboardProtocol::Legacy)
&& key.code == crossterm::event::KeyCode::Tab
&& key.modifiers == crossterm::event::KeyModifiers::CONTROL
{
return crate::input::encode_terminal_key(key, protocol);
}
if ghostty_prefers_herdr_text_encoding(&key) {
return crate::input::encode_terminal_key(key, protocol);
}
@ -3909,6 +3916,30 @@ mod tests {
assert_eq!(encoded, b"\t");
}
#[test]
fn ghostty_ctrl_tab_matches_the_pane_keyboard_protocol() {
let (tx, _rx) = mpsc::channel(4);
let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();
let legacy = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap();
let key = crate::input::TerminalKey::new(
crossterm::event::KeyCode::Tab,
crossterm::event::KeyModifiers::CONTROL,
);
assert_eq!(
legacy.encode_terminal_key(key.clone(), crate::input::KeyboardProtocol::Legacy),
b"\t"
);
let mut terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();
terminal.write(b"\x1b[>3u");
let kitty = GhosttyPaneTerminal::new(terminal, tx).unwrap();
assert_eq!(
kitty.encode_terminal_key(key, crate::input::KeyboardProtocol::Kitty { flags: 3 }),
b"\x1b[9;5u"
);
}
#[test]
fn ghostty_enter_backspace_release_in_legacy_pane_emits_nothing() {
let (tx, _rx) = mpsc::channel(4);