Skip to content

Commit 2df5598

Browse files
claudesinelaw
authored andcommitted
fix(terminal): send modified keys to the child pty correctly
Keys forwarded into an embedded terminal lost part of their chord, so a program running there could not tell several distinct keys apart. `key_to_pty_bytes` tested modifiers one at a time in an if/else-if chain per key, which collapsed every combination onto its first matching branch: Ctrl+Shift+Right reached the child as Ctrl+Right (`CSI 1;5C`, not `1;6`). Home/End/PageUp/PageDown accepted only Ctrl, so Shift+Home arrived bare. `KeyCode::F(n)` ignored modifiers outright — Shift+F3 arrived as plain F3, the outgoing-side twin of #699 — and dropped F13 and up. Alt was lost on every key with no parameterised sequence to carry it (Alt+Backspace, the readline delete-previous-word, arrived as a bare Backspace), Ctrl+Alt+key matched neither the Ctrl nor the Alt branch and fell through to the plain-character arm, and Alt + a non-ASCII character was truncated by an `as u8` cast. Encode the modifiers additively in one place instead, as xterm's `1 + shift|alt<<1|ctrl<<2|meta<<3` parameter, and build each sequence from shared helpers so a key cannot grow its own divergent chain again. Super and Hyper have no legacy encoding and are dropped; the kitty protocol is where they would survive, and the emulator does not speak it to the child. Established encodings are unchanged — the pre-existing tests pass untouched, and the new ones all fail against the old encoder.
1 parent 1ebbce5 commit 2df5598

1 file changed

Lines changed: 319 additions & 138 deletions

File tree

  • crates/fresh-editor/src/services/terminal

0 commit comments

Comments
 (0)