File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -229,4 +229,9 @@ class TextPainter {
229
229
return _paragraph.getPositionForOffset (offset);
230
230
}
231
231
232
+ TextRange getWordBoundary (TextPosition position) {
233
+ assert (! _needsLayout);
234
+ List <int > indices = _paragraph.getWordBoundary (position.offset);
235
+ return new TextRange (start: indices[0 ], end: indices[1 ]);
236
+ }
232
237
}
Original file line number Diff line number Diff line change @@ -232,19 +232,8 @@ class RenderEditableLine extends RenderBox {
232
232
}
233
233
234
234
TextSelection _selectWordAtOffset (TextPosition position) {
235
- // TODO(mpcomplete): Placeholder. Need to ask the engine for this info to do
236
- // it correctly.
237
- String str = text.toPlainText ();
238
- int start = position.offset - 1 ;
239
- while (start >= 0 && str[start] != ' ' )
240
- -- start;
241
- ++ start;
242
-
243
- int end = position.offset;
244
- while (end < str.length && str[end] != ' ' )
245
- ++ end;
246
-
247
- return new TextSelection (baseOffset: start, extentOffset: end);
235
+ TextRange word = _textPainter.getWordBoundary (position);
236
+ return new TextSelection (baseOffset: word.start, extentOffset: word.end);
248
237
}
249
238
250
239
Rect _caretPrototype;
You can’t perform that action at this time.
0 commit comments