Skip to content

Commit

Permalink
fix(textinput): use old cursor pos and simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IllusionMan1212 authored and meowgorithm committed Jan 19, 2022
1 parent daba232 commit 151d102
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ func (m *Model) deleteWordLeft() bool {
return m.deleteBeforeCursor()
}

oldPos := m.pos
blink := m.setCursor(m.pos - 1)
for unicode.IsSpace(m.value[m.pos]) {
if m.pos <= 0 {
Expand All @@ -433,11 +434,7 @@ func (m *Model) deleteWordLeft() bool {
}
}

if m.pos > len(m.value) {
m.value = m.value[:m.pos]
} else {
m.value = append(m.value[:m.pos], m.value[m.pos:]...)
}
m.value = append(m.value[:m.pos], m.value[oldPos:]...)

return blink
}
Expand Down

0 comments on commit 151d102

Please sign in to comment.