mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget: ensure buffer.Read does nothing to read zero bytes
This commit ensures that the edit buffer used by widget.Editor does not get EOF when trying to read zero bytes from the underlying buffer, which eliminates a panic when calling Editor.SelectedText(). Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -121,6 +121,9 @@ func assertCaret(t *testing.T, e *Editor, line, col, bytes int) {
|
||||
if bytes != caretBytes {
|
||||
t.Errorf("caret at buffer position %d, expected %d", caretBytes, bytes)
|
||||
}
|
||||
// Ensure that SelectedText() does not panic no matter what the
|
||||
// editor's state is.
|
||||
_ = e.SelectedText()
|
||||
}
|
||||
|
||||
type editMutation int
|
||||
|
||||
Reference in New Issue
Block a user