Skip to content

fix(desktop): translate macOS ⌥⌫ (Option+Backspace) to delete-previous-word in terminal - #5615

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
triage/issue-5604-29170844023
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
triage/issue-5604-29170844023

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What this addresses

Issue #5604 is a tracker consolidating many stale terminal-input issues. Rather than a single bug, it lists ~25 sub-issues. This PR takes one concrete, reproducible, and cleanly fixable item from that list — #2222 (macOS-native text-editing shortcuts) — and closes the specific gap that still reproduces.

The bug

translateLineEditChord (apps/desktop/src/renderer/lib/terminal/line-edit-translations.ts) already implements most of the macOS shortcuts #2222 asks for:

Shortcut Status before this PR
⌘← / ⌘→ (line start/end) ✅ implemented
⌘⌫ (delete to start of line) ✅ implemented
⌥← / ⌥→ (word movement) ✅ implemented
⌥⌫ (delete previous word) ❌ missing

The alt branch only handled ArrowLeft/ArrowRight, so Option+Backspace fell through the translator, got CSI-u encoded by xterm's kitty keyboard protocol, and did nothing useful in the shell — exactly the "Current Terminal Behavior: Nothing" row in #2222.

Root cause

translateLineEditChord's isMac && onlyMod(event, "alt") block mapped the two arrow keys but never Backspace, even though the sibling meta branch already handled Backspace (delete-to-start).

The fix

Add one mapping in the alt branch:

if (key === "Backspace") return "\x1b\x7f";

ESC + DEL (\x1b\x7f) is the readline/zsh backward-kill-word sequence. It respects word boundaries the same way native macOS text inputs do, and it's consistent across bash and zsh (unlike ⌘⌫'s \x15, whose meaning differs per shell).

Tests

line-edit-translations.test.ts:

  • Reproduction → new test asserting Mac Option+Backspace maps to \x1b\x7f. Before the fix it returned null (bug reproduced); after the fix it passes.
  • Guard → new test asserting Option+Backspace is not translated on non-Mac platforms.

All 9 tests in the file pass. (The 10 failing tests elsewhere in the terminal dir are pre-existing document is not defined DOM-environment issues in appearance.test.ts, unrelated to this change.)

Refs #5604
Closes #2222


Open in Stage

Summary by cubic

Adds macOS Option+Backspace (⌥⌫) support in the terminal so it deletes the previous word, translating to ESC+DEL and matching native behavior. Closes #2222; addresses the terminal-input tracker in #5604.

  • Bug Fixes
    • Map ⌥⌫ to ESC+DEL (\x1b\x7f) on macOS for backward-kill-word.
    • Add tests for macOS mapping and non-macOS pass-through.

Written for commit 3fc268a. Summary will update on new commits.

Review in cubic

…in terminal

Option+Backspace (⌥⌫) is a standard macOS text-editing shortcut for
deleting the previous word, but the terminal's line-edit chord translator
only handled Alt+Arrow (word movement) and Cmd+Backspace (delete to start
of line). ⌥⌫ fell through to xterm's kitty encoder and did nothing in the
shell.

Map it to ESC+DEL (\x1b\x7f), the readline/zsh backward-kill-word
sequence, matching the word-boundary behavior of native macOS inputs.

Refs #5604, Closes #2222
@ghost

ghost commented Jul 11, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 2 individual chapters for you:

Title
1 Map macOS Option+Backspace to backward-kill-word
2 Verify macOS word deletion shortcut translation
Open in Stage

Chapters generated by Stage for commit 3fc268a on Jul 11, 2026 10:43pm UTC.

This branch has not been deployed

No deployments
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.

Support macOS-native text editing shortcuts in terminal input

0 participants