fix: set value moves cursor only when empty and at starting position

This commit is contained in:
Maas Lalani 2022-10-06 11:31:02 -04:00
parent e857875f2a
commit d177512114

View File

@ -122,6 +122,7 @@ func (m *Model) SetValue(s string) {
} }
} }
empty := len(m.value) == 0
m.Err = nil m.Err = nil
runes := []rune(s) runes := []rune(s)
@ -130,7 +131,7 @@ func (m *Model) SetValue(s string) {
} else { } else {
m.value = runes m.value = runes
} }
if m.pos > len(m.value) { if (m.pos == 0 && empty) || m.pos > len(m.value) {
m.SetCursor(len(m.value)) m.SetCursor(len(m.value))
} }
m.handleOverflow() m.handleOverflow()