clipboard kitten: Fix a bug causing kitten to hang in filter mode when input data size is not divisible by 3 and larger than 8KB

Fixes #8059
This commit is contained in:
Kovid Goyal 2024-11-19 11:24:59 +05:30
parent 4cb190130f
commit 2436c5acfe
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 10 deletions

View file

@ -93,6 +93,8 @@ Detailed list of changes
- Wayland GNOME: Workaround bug in mutter causing double tap on titlebar to not always work (:iss:`8054`)
- clipboard kitten: Fix a bug causing kitten to hang in filter mode when input data size is not divisible by 3 and larger than 8KB (:iss:`8059`)
0.37.0 [2024-10-30]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -139,19 +139,24 @@ func run_plain_text_loop(opts *Options) (err error) {
buf := make([]byte, 8192)
write_one_chunk := func() error {
n, err := data_src.Read(buf[:cap(buf)])
if err != nil && !errors.Is(err, io.EOF) {
orig := enc_writer.last_written_id
for enc_writer.last_written_id == orig {
n, err := data_src.Read(buf[:cap(buf)])
if n > 0 {
enc.Write(buf[:n])
}
if err == nil {
continue
}
if errors.Is(err, io.EOF) {
enc.Close()
send_to_loop("\x1b\\")
after_read_from_stdin()
return nil
}
send_to_loop("\x1b\\")
return err
}
if n > 0 {
enc.Write(buf[:n])
}
if errors.Is(err, io.EOF) {
enc.Close()
send_to_loop("\x1b\\")
after_read_from_stdin()
}
return nil
}