From e9dd6b06e03997ce4127702ab14e87b27d6e7520 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 20 Jun 2020 23:30:19 -0400 Subject: [PATCH] Fix duplicate character bug when deleting chars in long strings If the string is longer than the width of the field and the horizontal viewport (so to speak) was on the right edge, the last character would repeat when deleting characters because the viewport offset wasn't being corrected. This fixes that. --- textinput/textinput.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/textinput/textinput.go b/textinput/textinput.go index d9ae1b9..ec35588 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -135,6 +135,9 @@ func (m *Model) handleOverflow() { return } + // Correct right offset if we've deleted characters + m.offsetRight = min(m.offsetRight, len(m.value)) + if m.pos < m.offset { m.offset = m.pos