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

Commit a6811ed

Browse files
committed
Changing return type for getWordBoundary to TextRange
1 parent 854a171 commit a6811ed

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/ui/text.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,15 +1882,17 @@ class Paragraph extends NativeFieldWrapperClass2 {
18821882
/// on both sides. In such cases, this method will return [offset, offset+1].
18831883
/// Word boundaries are defined more precisely in Unicode Standard Annex #29
18841884
/// http://www.unicode.org/reports/tr29/#Word_Boundaries
1885-
List<int> getWordBoundary(dynamic position) {
1885+
TextRange getWordBoundary(dynamic position) {
18861886
// TODO(gspencergoog): have this take only a TextPosition once the framework
18871887
// code is calling it with that.
1888+
List<int> boundary;
18881889
if (position is TextPosition) {
1889-
return _getWordBoundary(position.offset);
1890+
boundary = _getWordBoundary(position.offset);
18901891
} else {
18911892
final int offset = position;
1892-
return _getWordBoundary(offset);
1893+
boundary = _getWordBoundary(offset);
18931894
}
1895+
return TextRange(start: boundary[0], end: boundary[1]);
18941896
}
18951897
List<int> _getWordBoundary(int offset) native 'Paragraph_getWordBoundary';
18961898

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,27 +281,27 @@ class EngineParagraph implements ui.Paragraph {
281281
}
282282

283283
@override
284-
List<int> getWordBoundary(dynamic position) {
284+
ui.TextRange getWordBoundary(dynamic position) {
285285
// TODO(gspencergoog): have this take only a TextPosition once the framework
286286
// code is calling it with that.
287287
if (position is ui.TextPosition) {
288288
ui.TextPosition textPosition = position;
289289
if (_plainText == null) {
290-
return <int>[textPosition.offset, textPosition.offset];
290+
return ui.TextRange(start: textPosition.offset, end: textPosition.offset);
291291
}
292292

293293
final int start = WordBreaker.prevBreakIndex(_plainText, textPosition.offset);
294294
final int end = WordBreaker.nextBreakIndex(_plainText, textPosition.offset);
295-
return <int>[start, end];
295+
return ui.TextRange(start: start, end: end);
296296
}
297297

298298
if (_plainText == null) {
299-
return <int>[position, position];
299+
return ui.TextRange(start: position, end: position);
300300
}
301301

302302
final int start = WordBreaker.prevBreakIndex(_plainText, position);
303303
final int end = WordBreaker.nextBreakIndex(_plainText, position);
304-
return <int>[start, end];
304+
return ui.TextRange(start: start, end: end);
305305
}
306306

307307
@override

lib/web_ui/lib/src/ui/text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ abstract class Paragraph {
12501250
/// on both sides. In such cases, this method will return [offset, offset+1].
12511251
/// Word boundaries are defined more precisely in Unicode Standard Annex #29
12521252
/// http://www.unicode.org/reports/tr29/#Word_Boundaries
1253-
List<int> getWordBoundary(dynamic position);
1253+
TextRange getWordBoundary(dynamic position);
12541254

12551255
/// Returns the [start, end] of the line at the given offset.
12561256
///

0 commit comments

Comments
 (0)