diff --git a/textarea/textarea.go b/textarea/textarea.go index 769becf..d892468 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -6,6 +6,7 @@ import ( "crypto/sha256" "fmt" "image/color" + "slices" "strconv" "strings" "time" @@ -1125,7 +1126,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { } case key.Matches(msg, m.KeyMap.DeleteCharacterForward): if len(m.value[m.row]) > 0 && m.col < len(m.value[m.row]) { - m.value[m.row] = append(m.value[m.row][:m.col], m.value[m.row][m.col+1:]...) + m.value[m.row] = slices.Delete(m.value[m.row], m.col, m.col+1) } if m.col >= len(m.value[m.row]) { m.mergeLineBelow(m.row) diff --git a/textinput/textinput.go b/textinput/textinput.go index fe61757..1156001 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -4,6 +4,7 @@ package textinput import ( "reflect" + "slices" "strings" "unicode" @@ -624,7 +625,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.CursorStart() case key.Matches(msg, m.KeyMap.DeleteCharacterForward): if len(m.value) > 0 && m.pos < len(m.value) { - m.value = append(m.value[:m.pos], m.value[m.pos+1:]...) + m.value = slices.Delete(m.value, m.pos, m.pos+1) m.Err = m.validate(m.value) } case key.Matches(msg, m.KeyMap.LineEnd):