Skip to content

fix(textinput): handle shift+backspace in terminals with Kitty keyboard protocol#621

Open
matze wants to merge 1 commit intoidursun:mainfrom
matze:fix-shift-backspace
Open

fix(textinput): handle shift+backspace in terminals with Kitty keyboard protocol#621
matze wants to merge 1 commit intoidursun:mainfrom
matze:fix-shift-backspace

Conversation

@matze
Copy link
Copy Markdown

@matze matze commented Mar 29, 2026

Disclaimer: I am not a Go developer and this was mostly figured out by Claude Code.

Terminals like wezterm and ghostty on Linux report shift+backspace as a distinct key event via the Kitty keyboard protocol. The bubbles textinput default KeyMap only binds plain backspace, so shift+backspace was silently ignored. Add a PatchTextInputKeys helper that extends the KeyMap to also accept shift+backspace, shift+delete, and shift+alt+backspace, and apply it to all textinput instances.

Fixes #619

@matze matze requested a review from idursun as a code owner March 29, 2026 20:41
Copy link
Copy Markdown
Collaborator

@baggiiiie baggiiiie left a comment

Choose a reason for hiding this comment

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

hey @matze thanks for contributing, a few issues i think worth addressing here

Comment on lines +65 to +66
ti := textinput.New()
common.PatchTextInputKeys(&ti)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if we were to introduce this change, instead of a "patch", i think it's better to have something like common.TextInputNew() that does what PathTextInputKeys is doing and textinput.New()
it should be able to remove this two-step (textinput.New then PatchTextInput) boilerplate

otherwise every caller of textinput.New needs to call the patch

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed to your suggestion and now without AI :-)

)
km.DeleteWordBackward.SetKeys(
append(km.DeleteWordBackward.Keys(), "shift+alt+backspace")...,
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

intuitively, i think a DeleteWorkForward is missing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

But … with which key?

…rd protocol

Terminals like wezterm and ghostty on Linux report shift+backspace as a
distinct key event via the Kitty keyboard protocol. The bubbles textinput
default KeyMap only binds plain backspace, so shift+backspace was silently
ignored. Add a PatchTextInputKeys helper that extends the KeyMap to also
accept shift+backspace, shift+delete, and shift+alt+backspace, and apply
it to all textinput instances.

Fixes idursun#619
@matze matze force-pushed the fix-shift-backspace branch from c5603a6 to 70e5e11 Compare March 30, 2026 20:25
@idursun
Copy link
Copy Markdown
Owner

idursun commented Mar 30, 2026

Hey sorry for the late reply, but shouldn't this contribution be sent to the downstream https://github.com/charmbracelet/bubbles repository instead?

We don't own textarea/textinput and I personally don't think we should be patching downstream issues here.

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.

Shift + backspace does not delete the previous character

3 participants