File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -926,12 +926,11 @@ def get_widget_and_offset_at(
926926 offset_y : int | None = None
927927 offset_x = 0
928928 offset_x2 = 0
929- cell_position = 0
930929
931930 from rich .cells import get_character_cell_size
932931
933932 for segment in line :
934- end += len ( segment .text )
933+ end += segment .cell_length
935934 style = segment .style
936935 if style is not None and style ._meta is not None :
937936 meta = style .meta
@@ -940,25 +939,19 @@ def get_widget_and_offset_at(
940939 offset_x2 = offset_x + len (segment .text )
941940
942941 if x < end and x >= start :
943- if x == end - 1 :
944- segment_offset = len (segment .text )
945- else :
946- segment_cell_length = 0
947- cell_cut = x - cell_position
948- segment_offset = 0
949- for character in segment .text :
950- if segment_cell_length >= cell_cut :
951- break
952- segment_cell_length += get_character_cell_size (
953- character
954- )
955- segment_offset += 1
942+ segment_cell_length = 0
943+ cell_cut = x - start
944+ segment_offset = 0
945+ for character in segment .text :
946+ if segment_cell_length >= cell_cut :
947+ break
948+ segment_cell_length += get_character_cell_size (character )
949+ segment_offset += 1
956950 return widget , (
957951 None
958952 if offset_y is None
959953 else Offset (offset_x + segment_offset , offset_y )
960954 )
961- cell_position += cell_len (segment .text )
962955 start = end
963956
964957 return widget , (None if offset_y is None else Offset (offset_x2 , offset_y ))
You can’t perform that action at this time.
0 commit comments