Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rich/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def _cell_len(text: str, unicode_version: str) -> int:
for character in iter_characters:
if character in SPECIAL:
if character == "\u200d":
next(iter_characters)
try:
next(iter_characters)
except StopIteration:
break
elif last_measured_character:
total_width += last_measured_character in cell_table.narrow_to_wide
last_measured_character = None
Expand Down
8 changes: 8 additions & 0 deletions tests/test_zwj_cell_len.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from rich.cells import cell_len


def test_cell_len_zwj_does_not_raise() -> None:
cell_len("\u200d")
cell_len("a\u200d")
cell_len("a\u200d\n b")
cell_len("a\u200d b(")