← oracle_full

rich_3535

resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · Textualize/rich

Task input

Regex error

Fixes an issue with the regex used to select the fast path for strings with single-width characters.

This may have had a detrimental effect on performance for some operations.

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/rich/cells.py
+++ b/rich/cells.py
@@ -7,7 +7,9 @@
 from ._cell_widths import CELL_WIDTHS
 
 # Regex to match sequence of the most common character ranges
-_is_single_cell_widths = re.compile("^[\u0020-\u006f\u00a0\u02ff\u0370-\u0482]*$").match
+_is_single_cell_widths = re.compile(
+    "^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u2500-\u25FF]*$"
+).match
 
 
 @lru_cache(4096)
--- a/rich/segment.py
+++ b/rich/segment.py
@@ -161,10 +161,14 @@ def split_cells(self, cut: int) -> Tuple["Segment", "Segment"]:
         If the cut point falls in the middle of a 2-cell wide character then it is replaced
         by two spaces, to preserve the display width of the parent segment.
 
+        Args:
+            cut (int): Offset within the segment to cut.
+
         Returns:
             Tuple[Segment, Segment]: Two segments.
         """
         text, style, control = self
+        assert cut >= 0
 
         if _is_single_cell_widths(text):
             # Fast path with all 1 cell characters

Test output

show
........                                                                 [100%]
8 passed in 0.02s