Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b625681

Browse files
committed
Fix issue of previous PR
1 parent b5b9d90 commit b625681

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/web_ui/lib/src/engine/text/paragraph.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ class EngineParagraph implements ui.Paragraph {
383383
return getPositionForMultiSpanOffset(offset);
384384
}
385385

386+
// [offset] is above all the lines.
387+
if (offset.dy < 0) {
388+
return ui.TextPosition(
389+
offset: 0,
390+
affinity: ui.TextAffinity.downstream,
391+
);
392+
}
393+
386394
final int lineNumber = offset.dy ~/ _measurementResult.lineHeight;
387395

388396
// [offset] is below all the lines.

lib/web_ui/test/paragraph_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void main() async {
202202
);
203203
// Above the first line.
204204
expect(
205-
paragraph.getPositionForOffset(Offset(0, -5)),
205+
paragraph.getPositionForOffset(Offset(0, -15)),
206206
TextPosition(offset: 0, affinity: TextAffinity.downstream),
207207
);
208208
// At the end of the first line.

0 commit comments

Comments
 (0)