From db06ae17d341503687ca5bdebcf0e8d6d90a9c86 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Tue, 24 Jan 2023 19:37:11 +0100 Subject: [PATCH] fix(textarea): support pastes that end with a newline character My previous fix did not properly handle a multi-rune input that *ends* with a newline character. In that case, the final newline was removed. I found this using the test suite I built for textarea in bubbline at https://github.com/knz/bubbline/tree/main/editline/internal/textarea/testdata. --- textarea/textarea.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index fb86f08..c2419c8 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -325,7 +325,7 @@ func (m *Model) insertRunesFromUserInput(runes []rune) { lstart = i + 1 } } - if lstart < len(runes) { + if lstart <= len(runes) { // The last line did not end with a newline character. // Take it now. lines = append(lines, runes[lstart:])