mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-14 21:13:44 +03:00
fix(textinput): use old cursor pos and simplify logic
This commit is contained in:
parent
daba232df4
commit
151d1026dd
@ -412,6 +412,7 @@ func (m *Model) deleteWordLeft() bool {
|
|||||||
return m.deleteBeforeCursor()
|
return m.deleteBeforeCursor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldPos := m.pos
|
||||||
blink := m.setCursor(m.pos - 1)
|
blink := m.setCursor(m.pos - 1)
|
||||||
for unicode.IsSpace(m.value[m.pos]) {
|
for unicode.IsSpace(m.value[m.pos]) {
|
||||||
if m.pos <= 0 {
|
if m.pos <= 0 {
|
||||||
@ -433,11 +434,7 @@ func (m *Model) deleteWordLeft() bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.pos > len(m.value) {
|
m.value = append(m.value[:m.pos], m.value[oldPos:]...)
|
||||||
m.value = m.value[:m.pos]
|
|
||||||
} else {
|
|
||||||
m.value = append(m.value[:m.pos], m.value[m.pos:]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return blink
|
return blink
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user