File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -912,7 +912,7 @@ def get_widget_and_offset_at(
912912 offset_x2 = 0
913913
914914 for segment in lines [0 ]:
915- end += segment .cell_length
915+ end += len ( segment .text )
916916 style = segment .style
917917 if style is not None and style ._meta is not None :
918918 meta = style .meta
@@ -921,10 +921,11 @@ def get_widget_and_offset_at(
921921 offset_x2 = offset_x + len (segment .text )
922922
923923 if x <= end and x >= start :
924+ first , _ = segment .split_cells (x - start )
924925 return widget , (
925926 None
926927 if offset_y is None
927- else Offset (offset_x + ( x - start ), offset_y )
928+ else Offset (offset_x + len ( first . text ), offset_y )
928929 )
929930 start = end
930931
Original file line number Diff line number Diff line change @@ -3330,3 +3330,21 @@ def compose(self) -> ComposeResult:
33303330 yield Label ("This does not allow [bold]markup[/bold]" , markup = False )
33313331
33323332 snap_compare (LabelApp ())
3333+
3334+
3335+ def test_arbitrary_selection_double_cell (snap_compare ):
3336+ """Check that selection understands double width cells.
3337+
3338+ You should see a smiley face followed by 'Hello World!', where Hello is highlighted."""
3339+
3340+ class LApp (App ):
3341+ def compose (self ) -> ComposeResult :
3342+ yield Label ("😃Hello World!" )
3343+
3344+ async def run_before (pilot : Pilot ) -> None :
3345+ await pilot .pause ()
3346+ await pilot .mouse_down (Label , offset = (2 , 0 ))
3347+ await pilot .mouse_up (Label , offset = (7 , 0 ))
3348+ await pilot .pause ()
3349+
3350+ assert snap_compare (LApp (), run_before = run_before )
You can’t perform that action at this time.
0 commit comments