diff --git a/rich/cells.py b/rich/cells.py index af8e81c7b..4debea0ca 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -8,7 +8,7 @@ # Regex to match sequence of the most common character ranges _is_single_cell_widths = re.compile( - "^[\u0020-\u007f\u00a0\u02ff\u0370-\u0482\u2500-\u25FF]*$" + "^[\u0020-\u007e\u00a0\u02ff\u0370-\u0482\u2500-\u25FF]*$" ).match diff --git a/tests/test_cells.py b/tests/test_cells.py index fe451fa57..d694fb379 100644 --- a/tests/test_cells.py +++ b/tests/test_cells.py @@ -1,5 +1,7 @@ +import string + from rich import cells -from rich.cells import chop_cells +from rich.cells import _is_single_cell_widths, chop_cells def test_cell_len_long_string(): @@ -59,3 +61,22 @@ def test_chop_cells_mixed_width(): """Mixed single and double-width characters.""" text = "あ1り234が5と6う78" assert chop_cells(text, 3) == ["あ1", "り2", "34", "が5", "と6", "う7", "8"] + + +def test_is_single_cell_widths() -> None: + # Check _is_single_cell_widths reports correctly + for character in string.printable: + if ord(character) >= 32: + assert _is_single_cell_widths(character) + + BOX = "┌─┬┐│ ││├─┼┤│ ││├─┼┤├─┼┤│ ││└─┴┘" + + for character in BOX: + print(repr(character)) + assert _is_single_cell_widths(character) + + for character in "💩": + assert not _is_single_cell_widths(character) + + for character in "わさび": + assert not _is_single_cell_widths(character) diff --git a/tests/test_segment.py b/tests/test_segment.py index a9e649410..2264dbe50 100644 --- a/tests/test_segment.py +++ b/tests/test_segment.py @@ -1,16 +1,9 @@ -import string from io import StringIO import pytest from rich.cells import cell_len -from rich.segment import ( - ControlType, - Segment, - SegmentLines, - Segments, - _is_single_cell_widths, -) +from rich.segment import ControlType, Segment, SegmentLines, Segments from rich.style import Style @@ -385,22 +378,3 @@ def test_align_bottom(): [Segment(" ", Style())], [Segment("X")], ] - - -def test_is_single_cell_widths() -> None: - # Check _is_single_cell_widths reports correctly - for character in string.printable: - if ord(character) >= 32: - assert _is_single_cell_widths(character) - - BOX = "┌─┬┐│ ││├─┼┤│ ││├─┼┤├─┼┤│ ││└─┴┘" - - for character in BOX: - print(repr(character)) - assert _is_single_cell_widths(character) - - for character in "💩": - assert not _is_single_cell_widths(character) - - for character in "わさび": - assert not _is_single_cell_widths(character)