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:
@@ -113,6 +113,9 @@ func (e *editBuffer) Seek(offset int64, whence int) (ret int64, err error) {
|
||||
}
|
||||
|
||||
func (e *editBuffer) Read(p []byte) (int, error) {
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
if e.pos == e.len() {
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user