From a6a12c4a31ebfa225a55e5f7c0fff1c09060bb28 Mon Sep 17 00:00:00 2001 From: infastin <69149679+infastin@users.noreply.github.com> Date: Mon, 23 Jan 2023 23:10:21 +0500 Subject: [PATCH] fix(textarea): app would crash if deleteWordRight was called at the end of line (#313) * fix(textarea): app would crash if deleteWordRight was called at the end of line * fix(textarea): deleteWordRight would work incorrectly Co-authored-by: infastin --- textarea/textarea.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index cd425817b6..fb86f08941 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -623,14 +623,10 @@ func (m *Model) deleteWordRight() { } oldCol := m.col - m.SetCursor(m.col + 1) - for unicode.IsSpace(m.value[m.row][m.col]) { + + for m.col < len(m.value[m.row]) && unicode.IsSpace(m.value[m.row][m.col]) { // ignore series of whitespace after cursor m.SetCursor(m.col + 1) - - if m.col >= len(m.value[m.row]) { - break - } } for m.col < len(m.value[m.row]) {