fix(clipboard): record streamed clipboard writes in the history

OSC 52 writes are committed as a chunker factory rather than bytes, so the
history silently dropped every text copy made by a program. Extract the text
from either representation, bounded so a huge write is not materialized.
This commit is contained in:
BlackAngelTV committed 2026-11-11 21:32:09 +01:00
1 parent 831852a89f
commit 44b9aa166e
3 files changed
+68 -5

No files matched your search

+5 -4
View File
@@ -9,6 +9,7 @@ from gettext import gettext as _
from tempfile import TemporaryFile
from typing import IO, NamedTuple, Union
from .clipboard_history import text_from_mime_data
from .conf.utils import uniq
from .constants import supports_primary_selection
from .fast_data_types import (
@@ -113,15 +114,15 @@ class Clipboard:
# history itself, so that secrets never reach it.
if self.clipboard_type is not ClipboardType.clipboard:
return
data = self.data.get('text/plain')
if not isinstance(data, bytes):
if 'text/plain' not in self.data:
return
try:
text = data.decode('utf-8')
# The payload can be a chunker rather than bytes, as writes are streamed from a temp file
text = text_from_mime_data(self.data['text/plain'])
history = getattr(get_boss(), 'clipboard_history', None)
except Exception:
return
if history is not None:
if text and history is not None:
history.add(text, private=private)
def get_text(self) -> str: