Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion textarea/textarea.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func DefaultKeyMap() KeyMap {
DeleteAfterCursor: key.NewBinding(key.WithKeys("ctrl+k"), key.WithHelp("ctrl+k", "delete after cursor")),
DeleteBeforeCursor: key.NewBinding(key.WithKeys("ctrl+u"), key.WithHelp("ctrl+u", "delete before cursor")),
InsertNewline: key.NewBinding(key.WithKeys("enter", "ctrl+m"), key.WithHelp("enter", "insert newline")),
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "ctrl+h"), key.WithHelp("backspace", "delete character backward")),
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "shift+backspace", "ctrl+h"), key.WithHelp("backspace", "delete character backward")),
DeleteCharacterForward: key.NewBinding(key.WithKeys("delete", "ctrl+d"), key.WithHelp("delete", "delete character forward")),
LineStart: key.NewBinding(key.WithKeys("home", "ctrl+a"), key.WithHelp("home", "line start")),
LineEnd: key.NewBinding(key.WithKeys("end", "ctrl+e"), key.WithHelp("end", "line end")),
Expand Down
11 changes: 11 additions & 0 deletions textarea/textarea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,17 @@ func TestDynamicHeight_ShrinksWhenScrolledNoMaxContent(t *testing.T) {
}
}

func TestShiftBackspaceDeletesCharacterBackward(t *testing.T) {
ta := newTextArea()
ta.SetValue("abc")

ta, _ = ta.Update(tea.KeyPressMsg{Code: tea.KeyBackspace, Mod: tea.ModShift})

if got, want := ta.Value(), "ab"; got != want {
t.Errorf("after shift+backspace got %q, want %q", got, want)
}
}

func newTextArea() Model {
textarea := New()

Expand Down
2 changes: 1 addition & 1 deletion textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func DefaultKeyMap() KeyMap {
DeleteWordForward: key.NewBinding(key.WithKeys("alt+delete", "alt+d")),
DeleteAfterCursor: key.NewBinding(key.WithKeys("ctrl+k")),
DeleteBeforeCursor: key.NewBinding(key.WithKeys("ctrl+u")),
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "ctrl+h")),
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "shift+backspace", "ctrl+h")),
DeleteCharacterForward: key.NewBinding(key.WithKeys("delete", "ctrl+d")),
LineStart: key.NewBinding(key.WithKeys("home", "ctrl+a")),
LineEnd: key.NewBinding(key.WithKeys("end", "ctrl+e")),
Expand Down
12 changes: 12 additions & 0 deletions textinput/textinput_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ func ExampleValidateFunc() {
}
}

func TestShiftBackspaceDeletesCharacterBackward(t *testing.T) {
ti := New()
ti.Focus()
ti.SetValue("abc")

ti, _ = ti.Update(tea.KeyPressMsg{Code: tea.KeyBackspace, Mod: tea.ModShift})

if got, want := ti.Value(), "ab"; got != want {
t.Errorf("after shift+backspace got %q, want %q", got, want)
}
}

func keyPress(key rune) tea.Msg {
return tea.KeyPressMsg{Code: key, Text: string(key)}
}
Expand Down