Fix RuneReader breaking right before EOF

This commit is contained in:
2024-09-17 20:48:38 -06:00
parent edff0f8ca0
commit 5e9566be33
2 changed files with 39 additions and 4 deletions

View File

@ -35,10 +35,14 @@ func (rr *RuneReader) ReadRune() (r rune, size int, err error) {
rr.cursor = next
return 0, 0, fmt.Errorf("ReadRune: %w", err)
}
if n == 0 {
return 0, 0, io.EOF
}
s = s[:n]
fmt.Println("read bytes:", s)
r, size = utf8.DecodeRune(s)
rr.cursor = rr.cursor.At(rr.cursor.Pos() + uint64(size))
return r, size, err
return r, size, nil
}
func (rr *RuneReader) Cursor() cursor.Cursor[byte] {