From ed7378938303f32ad71efdf739b4b176598542a0 Mon Sep 17 00:00:00 2001 From: Hong Minhee Date: Fri, 10 Feb 2023 22:05:20 +0900 Subject: [PATCH] Let width table treat 0-width chars as 1-width --- scripts/make_width_table.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/make_width_table.py b/scripts/make_width_table.py index f15631e2bd0..09aca9c34b5 100644 --- a/scripts/make_width_table.py +++ b/scripts/make_width_table.py @@ -28,7 +28,11 @@ def make_width_table() -> Iterable[Tuple[int, int, int]]: range_width = -2 for codepoint in range(0, sys.maxunicode + 1): width = wcwidth.wcwidth(chr(codepoint)) - if width == 1: + if width <= 1: + # Ignore narrow characters along with zero-width characters so that + # they are treated as single-width. Note that treating zero-width + # characters as single-width is consistent with the heuristics built + # on top of str.isascii() in the str_width() function in strings.py. continue if start_codepoint < 0: start_codepoint = codepoint