Fix a regression that broke rendering of unicode regional indicators

At some point, unicode regional indicators became combining chars in the
unicode standard, which broke the handling of them in draw_codepoint().
The fix has the added advantage of improving performance in the common
case by only checking for combining chars. The flag check happens only
if the first check matches.

Fixes #4407
This commit is contained in:
Kovid Goyal
2021-12-31 09:28:47 +05:30
parent ea63efa522
commit e45697f78a
3 changed files with 21 additions and 7 deletions

View File

@@ -110,6 +110,17 @@ class TestScreen(BaseTest):
self.ae(str(s.line(0)), q)
self.ae(s.cursor.x, 2)
def test_regional_indicators(self):
s = self.create_screen()
flag = '\U0001f1ee\U0001f1f3'
s.draw(flag)
self.ae(str(s.line(0)), flag)
self.ae(s.cursor.x, 2)
s = self.create_screen()
s.draw('a'), s.draw(flag[0]), s.draw('b')
self.ae(str(s.line(0)), 'a' + flag[0] + 'b')
self.ae(s.cursor.x, 4)
def test_zwj(self):
s = self.create_screen(cols=20)
q = '\U0001f468\u200d\U0001f469\u200d\U0001f467\u200d\U0001f466'