Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/text/canvas_paragraph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class CanvasParagraph implements ui.Paragraph {
}

final ParagraphLine line = lines[i];
return ui.TextRange(start: line.startIndex, end: line.endIndex);
return ui.TextRange(start: line.startIndex, end: line.endIndex - line.trailingNewlines);
}

@override
Expand Down
6 changes: 4 additions & 2 deletions lib/web_ui/test/text/canvas_paragraph_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ Future<void> testMain() async {
for (int i = 0; i < 11; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
const ui.TextRange(start: 0, end: 11),
// The "\n" is not included in the line boundary.
const ui.TextRange(start: 0, end: 10),
reason: 'failed at offset $i',
);
}
Expand All @@ -709,7 +710,8 @@ Future<void> testMain() async {
for (int i = 11; i < 23; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
const ui.TextRange(start: 11, end: 23),
// The "\n" is not included in the line boundary.
const ui.TextRange(start: 11, end: 22),
reason: 'failed at offset $i',
);
}
Expand Down