selectionClaim seeks to the start of the data before reading it

This commit is contained in:
Sasha Koshka 2023-03-30 18:42:40 -04:00
parent a16f3c2cd7
commit 17422cc054
2 changed files with 2 additions and 1 deletions

View File

@ -153,6 +153,7 @@ func (claim *selectionClaim) handleSelectionRequest (
if confidence == confidenceNone { die(); return }
reader, ok := claim.data[mime]
if !ok { die(); return }
reader.Seek(0, io.SeekStart)
data, err := io.ReadAll(reader)
if err != nil { die() }
claim.window.fulfillSelectionRequest(data, 32, event)

View File

@ -5,7 +5,7 @@ import "bytes"
// Data represents arbitrary polymorphic data that can be used for data transfer
// between applications.
type Data map[Mime] io.ReadCloser
type Data map[Mime] io.ReadSeekCloser
// Mime represents a MIME type.
type Mime struct {