gh-121609: Fix pasting of characters containing unicode character joiner (#121667)

This commit is contained in:
Marta Gómez Macías 2024-07-13 12:44:18 +02:00 committed by GitHub
parent 18015451d0
commit e745996b2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -58,7 +58,6 @@ def disp_str(buffer: str) -> tuple[str, list[int]]:
elif unicodedata.category(c).startswith("C"):
c = r"\u%04x" % ord(c)
s.append(c)
b.append(str_width(c))
b.extend([0] * (len(c) - 1))
else:
s.append(c)

View file

@ -88,6 +88,12 @@ def test_setpos_for_xy_simple(self):
reader.setpos_from_xy(0, 0)
self.assertEqual(reader.pos, 0)
def test_control_characters(self):
code = 'flag = "🏳️‍🌈"'
events = code_to_events(code)
reader, _ = handle_all_events(events)
self.assert_screen_equals(reader, 'flag = "🏳️\\u200d🌈"')
def test_setpos_from_xy_multiple_lines(self):
# fmt: off
code = (

View file

@ -0,0 +1 @@
Fix pasting of characters containing unicode character joiners in the new REPL. Patch by Marta Gomez Macias