Commit 4b6f3652 authored by Kai Willadsen's avatar Kai Willadsen

sourceview: Fix pasting multi-byte encodings (#179)

For this API, pygobject isn't handling string length arguments for us,
so we had to do it ourselves. Shockingly, I got it very wrong. The API
requires a UTF-8 encoded string (which pygobject transparently encoded
for us) but the length arg has to be the bytestring length, not the
unicode codepoint length, which is what we were previously passing
along.
parent 9d35ffe4
......@@ -170,7 +170,10 @@ class MeldSourceView(GtkSource.View):
# contain GtkTextTags, by requesting and setting plain text.
def text_received_cb(clipboard, text, *user_data):
clipboard.set_text(text, len(text))
# Manual encoding is required here, or the length will be
# incorrect, and the API requires a UTF-8 bytestring.
utf8_text = text.encode('utf-8')
clipboard.set_text(text, len(utf8_text))
self.get_buffer().paste_clipboard(
clipboard, None, self.get_editable())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment