Skip to content

Commit 7657a9e

Browse files
committed
snapshot
1 parent 2852b12 commit 7657a9e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/textual/_compositor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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

tests/snapshot_tests/test_snapshots.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)