Skip to content

Commit d159b28

Browse files
authored
Support Alt+Backspace for word deletion in text areas (#4741)
- **PR Description** Add support for Alt+Backspace (Option+Backspace on macOS) to delete entire words in text input areas, matching common text editor behavior.
2 parents 1210a64 + 6956706 commit d159b28

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/gui/editors.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88

99
func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool {
1010
switch {
11+
case (key == gocui.KeyBackspace || key == gocui.KeyBackspace2) && (mod&gocui.ModAlt) != 0,
12+
key == gocui.KeyCtrlW:
13+
textArea.BackSpaceWord()
1114
case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
1215
textArea.BackSpaceChar()
1316
case key == gocui.KeyCtrlD || key == gocui.KeyDelete:
@@ -42,8 +45,6 @@ func (gui *Gui) handleEditorKeypress(textArea *gocui.TextArea, key gocui.Key, ch
4245
textArea.GoToStartOfLine()
4346
case key == gocui.KeyCtrlE || key == gocui.KeyEnd:
4447
textArea.GoToEndOfLine()
45-
case key == gocui.KeyCtrlW:
46-
textArea.BackSpaceWord()
4748
case key == gocui.KeyCtrlY:
4849
textArea.Yank()
4950

0 commit comments

Comments
 (0)