widget: fix editBuffer.WriteTo for short writes

Noticed while working in the area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-01-13 13:14:40 +01:00
parent abd8c2c9a3
commit 72c48a3c18
+1 -1
View File
@@ -161,7 +161,7 @@ func (e *editBuffer) ReadRune() (rune, int, error) {
// WriteTo implements io.WriterTo.
func (e *editBuffer) WriteTo(w io.Writer) (int64, error) {
n1, err := w.Write(e.text[:e.gapstart])
if err != nil {
if err != nil || n1 < e.gapstart {
return int64(n1), err
}
n2, err := w.Write(e.text[e.gapend:])