Skip to content

Commit 9214bae

Browse files
Copilotkovidgoyal
andauthored
dnd kitten: remove empty-payload EOF QueueDnDData calls for thumbnails
The empty-payload second QueueDnDData call in set_drag_image() and set_drag_image_text() triggered base64_decode_stream on an already- completed (padded) stream, which returns failure. This caused cancel_drag → drag_free_offer to run, destroying all drag state before drag_start was called from t=P:x=-1. As a result, drag_remote_file_data found no item with requested_remote_files set and aborted with EINVAL. The empty EOF call was never needed: drag_add_image only accumulates decoded bytes; the actual image processing happens later in drag_start. This mirrors the same fix already applied to the MIME pre-send path. Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/8bb89dc9-fd72-41c5-892b-2a15c658b313 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
1 parent b9a8784 commit 9214bae

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

kittens/dnd/drag.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ func (dnd *dnd) set_drag_image_text() (err error) {
116116
if icon == "" {
117117
icon = strings.TrimSpace("󰮐 ")
118118
}
119-
cmd := DC{Type: 'p', X: -1, Xp: 6, Yp: 1, Payload: []byte(icon)}
120-
dnd.lp.QueueDnDData(cmd)
121-
cmd.Payload = nil
122-
dnd.lp.QueueDnDData(cmd)
119+
dnd.lp.QueueDnDData(DC{Type: 'p', X: -1, Xp: 6, Yp: 1, Payload: []byte(icon)})
123120
return nil
124121
}
125122

@@ -151,12 +148,9 @@ func (dnd *dnd) set_drag_image() (err error) {
151148
} else {
152149
pix = imaging.AsRGBAData8(img)
153150
}
154-
cmd := DC{
151+
dnd.lp.QueueDnDData(DC{
155152
Type: 'p', X: -1, Y: utils.IfElse(num_channels == 3, 24, 32), Xp: img.Bounds().Dx(), Yp: img.Bounds().Dy(),
156-
Payload: pix}
157-
dnd.lp.QueueDnDData(cmd)
158-
cmd.Payload = nil
159-
dnd.lp.QueueDnDData(cmd)
153+
Payload: pix})
160154
return nil
161155
}
162156

0 commit comments

Comments
 (0)