From fe882dad15e77ed86bffa38018ec82e254b1888c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 May 2019 19:50:49 +0530 Subject: [PATCH] Add support for Vs-15 to wcswidth --- kitty/screen.c | 5 +++++ kitty_tests/datatypes.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/kitty/screen.c b/kitty/screen.c index c7a04296a..fad5429fb 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1734,6 +1734,11 @@ screen_wcswidth(PyObject UNUSED *self, PyObject *str) { ans += 1; prev_width = 2; } else prev_width = 0; + } else if (ch == 0xfe0e) { + if (is_emoji_presentation_base(prev_ch) && prev_width == 2) { + ans -= 1; + prev_width = 1; + } else prev_width = 0; } else { int w = wcwidth_std(ch); switch(w) { diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index a506a8dca..b1d770c79 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -344,6 +344,8 @@ class TestDataTypes(BaseTest): self.ae(tuple(map(w, 'a1\0コニチ ✔')), (1, 1, 0, 2, 2, 2, 1, 1)) self.ae(wcswidth('\u2716\u2716\ufe0f\U0001f337'), 5) self.ae(wcswidth('\033a\033[2mb'), 2) + self.ae(wcswidth('\u25b6\ufe0f'), 2) + self.ae(wcswidth('\U0001f610\ufe0e'), 1) # Regional indicator symbols (unicode flags) are defined as having # Emoji_Presentation so must have width 2 self.ae(tuple(map(w, '\U0001f1ee\U0001f1f3')), (2, 2))