failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · Textualize/rich
Fix ZWJ and edge cases Fixes https://github.com/Textualize/rich/issues/3947 Fixes https://github.com/Textualize/rich/issues/3950
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
......................................................F
=================================== FAILURES ===================================
___________________________________ test_zwj ___________________________________
def test_zwj():
"""Test special case of zero width joiners"""
assert cell_len("") == 0
> assert cell_len("\u200d") == 0
tests/test_cells.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rich/cells.py:106: in cell_len
return cached_cell_len(text, unicode_version)
rich/cells.py:92: in cached_cell_len
return _cell_len(text, unicode_version)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
text = '\u200d', unicode_version = 'auto'
def _cell_len(text: str, unicode_version: str) -> int:
"""Get the cell length of a string (length as it appears in the terminal).
Args:
text: String to measure.
unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.
Returns:
Length of string in terminal cells.
"""
if _is_single_cell_widths(text):
return len(text)
# "\u200d" is zero width joiner
# "\ufe0f" is variation selector 16
if "\u200d" not in text and "\ufe0f" not in text:
# Simplest case with no unicode stuff that changes the size
return sum(
get_character_cell_size(character, unicode_version) for character in text
)
cell_table = load_cell_table(unicode_version)
total_width = 0
last_measured_character: str | None = None
SPECIAL = {"\u200d", "\ufe0f"}
iter_characters = iter(text)
for character in iter_characters:
if character in SPECIAL:
if character == "\u200d":
> next(iter_characters)
E StopIteration
rich/cells.py:143: StopIteration
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 54 passed in 0.05s