From d1775121146a88a44a48562490cf08b7dd9df1c4 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 6 Oct 2022 11:31:02 -0400 Subject: [PATCH] fix: set value moves cursor only when empty and at starting position --- textinput/textinput.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/textinput/textinput.go b/textinput/textinput.go index c596910..8258130 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -122,6 +122,7 @@ func (m *Model) SetValue(s string) { } } + empty := len(m.value) == 0 m.Err = nil runes := []rune(s) @@ -130,7 +131,7 @@ func (m *Model) SetValue(s string) { } else { 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.handleOverflow()