Skip to content

Commit db2e3e8

Browse files
committed
assert cut
1 parent 68e1b63 commit db2e3e8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rich/segment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ def split_cells(self, cut: int) -> Tuple["Segment", "Segment"]:
161161
If the cut point falls in the middle of a 2-cell wide character then it is replaced
162162
by two spaces, to preserve the display width of the parent segment.
163163
164+
Args:
165+
cut (int): Offset within the segment to cut.
166+
164167
Returns:
165168
Tuple[Segment, Segment]: Two segments.
166169
"""
167170
text, style, control = self
171+
assert cut >= 0
168172

169173
if _is_single_cell_widths(text):
170174
# Fast path with all 1 cell characters

0 commit comments

Comments
 (0)