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(
912
912
offset_x2 = 0
913
913
914
914
for segment in lines [0 ]:
915
- end += segment .cell_length
915
+ end += len ( segment .text )
916
916
style = segment .style
917
917
if style is not None and style ._meta is not None :
918
918
meta = style .meta
@@ -921,10 +921,11 @@ def get_widget_and_offset_at(
921
921
offset_x2 = offset_x + len (segment .text )
922
922
923
923
if x <= end and x >= start :
924
+ first , _ = segment .split_cells (x - start )
924
925
return widget , (
925
926
None
926
927
if offset_y is None
927
- else Offset (offset_x + ( x - start ), offset_y )
928
+ else Offset (offset_x + len ( first . text ), offset_y )
928
929
)
929
930
start = end
930
931
Original file line number Diff line number Diff line change @@ -3330,3 +3330,21 @@ def compose(self) -> ComposeResult:
3330
3330
yield Label ("This does not allow [bold]markup[/bold]" , markup = False )
3331
3331
3332
3332
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