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.
This commit is contained in:
Christian Rocha
2020-06-20 23:30:19 -04:00
parent 7cef3a6f59
commit e9dd6b06e0

View File

@@ -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