Fix Ctrl+Backspace not deleting word in terminal

Restty does not map Ctrl+Backspace to backward-kill-word by default.
Intercept the key combination at the capture phase and send \x17 via
sendKeyInput so it reaches the PTY process directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matheus Nogueira
2026-03-19 20:12:12 -03:00
co-authored by Claude Opus 4.6
parent 36bea97080
commit 0abe12eb9a
+21 -1
View File
@@ -841,8 +841,28 @@ export default function TerminalPane({
}
}
// Ctrl+Backspace → send \x17 (backward-kill-word) to PTY.
// Most terminal emulators map this shortcut but xterm.js/Restty does not
// by default, so we intercept at the capture phase and forward manually.
const onCtrlBackspace = (e: KeyboardEvent): void => {
if (!e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return
if (e.key !== 'Backspace') return
const restty = resttyRef.current
if (!restty) return
e.preventDefault()
e.stopPropagation()
const pane = restty.getActivePane() ?? restty.getPanes()[0]
pane?.app.sendKeyInput('\x17')
}
window.addEventListener('keydown', onKeyDown, { capture: true })
return () => window.removeEventListener('keydown', onKeyDown, { capture: true })
window.addEventListener('keydown', onCtrlBackspace, { capture: true })
return () => {
window.removeEventListener('keydown', onKeyDown, { capture: true })
window.removeEventListener('keydown', onCtrlBackspace, { capture: true })
}
}, [isActive])
const resolveMenuPane = () => {