Avoid extra roundtrip when only reading clipboard mime types

This commit is contained in:
Kovid Goyal 2022-12-03 08:06:48 +05:30
parent bde737fa38
commit 26e8a5186a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -287,14 +287,19 @@ func run_get_loop(opts *Options, args []string) (err error) {
if err != nil {
return err
}
requested_mimes[o.remote_mime_type] = o
if o.remote_mime_type == "." {
o.started = true
o.add_data(utils.UnsafeStringToBytes(strings.Join(available_mimes, "\n")))
o.all_data_received = true
} else {
requested_mimes[o.remote_mime_type] = o
}
}
if len(requested_mimes) > 0 {
lp.QueueWriteString(encode(map[string]string{"type": "read"}, strings.Join(utils.Keys(requested_mimes), " ")))
} else {
lp.Quit(0)
}
default:
return fmt.Errorf("Failed to read list of available data types in the clipboard with error: %w", error_from_status(metadata["status"]))
}