diff --git a/rich/cells.py b/rich/cells.py index dead6174..6e532208 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -150,7 +150,9 @@ def _cell_len(text: str, unicode_version: str) -> int: while index < character_count: character = text[index] if character in SPECIAL: - if character == "\ufe0f" and last_measured_character: + if character == "\u200d": + index += 1 + elif character == "\ufe0f" and last_measured_character: total_width += last_measured_character in cell_table.narrow_to_wide last_measured_character = None else: diff --git a/tests/test_cells.py b/tests/test_cells.py index 7da1d032..f101740a 100644 --- a/tests/test_cells.py +++ b/tests/test_cells.py @@ -194,7 +194,9 @@ def test_zwj(): assert cell_len("") == 0 assert cell_len("\u200d") == 0 assert cell_len("1\u200d") == 1 - assert cell_len("1\u200d2") == 2 + # This sequence should really produce 2, but it aligns with with wcwidth + # What gets written to the terminal is anybody's guess, I've seen multiple variations + assert cell_len("1\u200d2") == 1 def test_non_printable():