Skip to content

Commit

Permalink
fix(textarea): app would crash if deleteWordRight was called at the e…
Browse files Browse the repository at this point in the history
…nd of line (charmbracelet#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 <thecookied123@gmail.com>
  • Loading branch information
infastin and infastin committed Jan 23, 2023
1 parent 4a71cee commit a6a12c4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions textarea/textarea.go
Expand Up @@ -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]) {
Expand Down

0 comments on commit a6a12c4

Please sign in to comment.