Skip to content

armgit / herdr

Public Imported from GitHub
0

the runtime your coding agents live on

fix: avoid ctrl-tab escape sequences in legacy panes

Ogulcan Celikea047db8e47d
diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs
index 4bd506694..58de71ce1 100644
--- a/src/pane/terminal.rs
+++ b/src/pane/terminal.rs
@@ -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);