[web] Don't include end-of-line characters in line boundary (flutter/engine#39693)

This commit is contained in:
Mouad Debbar 2023-02-17 18:27:19 -05:00 committed by GitHub
parent 66844e38d2
commit f027ff2c95
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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',
);
}
@ -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',
);
}