Skip to content

Send ESC DEL for Alt+Backspace and BS for Ctrl+Backspace - #167

Merged
tomlm merged 3 commits into
tomlm:mainfrom
alexeyzimarev:alexeyzimarev/backspace-modifiers
Oct 13, 2026
Merged

tomlm merged 3 commits into
tomlm:mainfrom
alexeyzimarev:alexeyzimarev/backspace-modifiers

Conversation

@alexeyzimarev

Copy link
Copy Markdown
Contributor

Fixes #166.

KeyboardInputGenerator mapped Key.Backspace to DEL whatever the modifiers, so a shell deleted one character for Alt+Backspace and could not tell Ctrl+Backspace from a plain one. This mirrors the xterm.js rule (Keyboard.ts, case 8): ^H when Ctrl is held, DEL otherwise, and an ESC prefix when Alt is held.

Call Before After
Backspace, Alt \x7f \x1b\x7f
Backspace, Control \x7f \x08
Backspace, Control + Alt \x7f \x1b\x08

Only the legacy path changes; the kitty encoding of the same chords was already correct. Two tests added in KeyboardInputTests; the whole suite passes.

The legacy generator mapped Backspace to DEL whatever the modifiers, so a shell deleted one character for Alt+Backspace. Mirrors xterm.js Keyboard.ts, case 8.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented behavior and covers all changed combinations.

0 open findings

What changed in this PR

Updates legacy Backspace encoding to match xterm.js and shell expectations.

Changes:

  • Sends BS for Ctrl+Backspace and prefixes Alt combinations with ESC.
  • Adds coverage for Alt, Ctrl, and Ctrl+Alt combinations.
File Description
KeyboardInputGenerator.cs Implements modifier-aware Backspace encoding.
KeyboardInputTests.cs Tests the new legacy sequences.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy Backspace drops Alt and Ctrl: ESC DEL and ^H are never sent

3 participants