diff --git a/kitty/clipboard.py b/kitty/clipboard.py index 53a490c13..2cf52ffb2 100644 --- a/kitty/clipboard.py +++ b/kitty/clipboard.py @@ -281,7 +281,7 @@ class WriteRequest: def flush_base64_data(self) -> None: if self.currently_writing_mime: - self.decoder.flush() + self.decoder.reinitialize() if len(self.decoder): self.write_base64_data(b'') start = self.mime_map[self.currently_writing_mime][0] diff --git a/kitty/data-types.c b/kitty/data-types.c index d210a1ec6..16347d6e4 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -163,7 +163,7 @@ static Py_ssize_t StreamingBase64Decoder_len(PyObject *s) { return ((StreamingBase64Decoder*)s)->output_sz; } static PyObject* -StreamingBase64Decoder_flush(StreamingBase64Decoder *self, PyObject *args UNUSED) { +StreamingBase64Decoder_reinitialize(StreamingBase64Decoder *self, PyObject *args UNUSED) { base64_stream_decode_init(&self->state, 0); Py_RETURN_NONE; } @@ -191,7 +191,7 @@ static PyTypeObject StreamingBase64Decoder_Type = { .tp_doc = "StreamingBase64Decoder", .tp_methods = (PyMethodDef[]){ {"add", (PyCFunction)StreamingBase64Decoder_add, METH_O, ""}, - {"flush", (PyCFunction)StreamingBase64Decoder_flush, METH_NOARGS, ""}, + {"reinitialize", (PyCFunction)StreamingBase64Decoder_reinitialize, METH_NOARGS, ""}, {"take_output", (PyCFunction)StreamingBase64Decoder_take_output, METH_NOARGS, ""}, {"copy_output", (PyCFunction)StreamingBase64Decoder_copy_output, METH_NOARGS, ""}, {NULL, NULL, 0, NULL}, diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 6077325fb..33747fe40 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1707,7 +1707,7 @@ def get_mouse_data_for_window(os_window_id: int, tab_id: int, window_id: int) -> class StreamingBase64Decoder: def __init__(self, initial_capacity: int = 8 *1024) -> None: ... # set the initial output buffer capacity def add(self, data: ReadOnlyBuffer) -> int: ... # add the base64 data - def flush(self) -> None: ... # indicate end of base64 data, left over bytes are processed as if they were followed by padding + def reinitialize(self) -> None: ... # reset the state to empty to start decoding a new stream def take_output(self) -> bytes: ... # take the output so far. The decoder no longer references this output def copy_output(self) -> bytes: ... # copy the output so far def __len__(self) -> int: ... # return the length of the current output diff --git a/kitty/notifications.py b/kitty/notifications.py index e77b8ee7c..3068d9be5 100644 --- a/kitty/notifications.py +++ b/kitty/notifications.py @@ -183,7 +183,7 @@ class EncodedDataStore: self.data_store(self.decoder.take_output()) def flush_encoded_data(self) -> None: - self.decoder.flush() + self.decoder.reinitialize() if len(self.decoder): self.data_store(self.decoder.take_output())