Use engine's getWordBoundary method when user selects a word. (#3851)
This commit is contained in:
parent
616d9e2ea8
commit
03141c2cdd
@ -229,4 +229,9 @@ class TextPainter {
|
||||
return _paragraph.getPositionForOffset(offset);
|
||||
}
|
||||
|
||||
TextRange getWordBoundary(TextPosition position) {
|
||||
assert(!_needsLayout);
|
||||
List<int> indices = _paragraph.getWordBoundary(position.offset);
|
||||
return new TextRange(start: indices[0], end: indices[1]);
|
||||
}
|
||||
}
|
||||
|
@ -232,19 +232,8 @@ class RenderEditableLine extends RenderBox {
|
||||
}
|
||||
|
||||
TextSelection _selectWordAtOffset(TextPosition position) {
|
||||
// TODO(mpcomplete): Placeholder. Need to ask the engine for this info to do
|
||||
// it correctly.
|
||||
String str = text.toPlainText();
|
||||
int start = position.offset - 1;
|
||||
while (start >= 0 && str[start] != ' ')
|
||||
--start;
|
||||
++start;
|
||||
|
||||
int end = position.offset;
|
||||
while (end < str.length && str[end] != ' ')
|
||||
++end;
|
||||
|
||||
return new TextSelection(baseOffset: start, extentOffset: end);
|
||||
TextRange word = _textPainter.getWordBoundary(position);
|
||||
return new TextSelection(baseOffset: word.start, extentOffset: word.end);
|
||||
}
|
||||
|
||||
Rect _caretPrototype;
|
||||
|
Loading…
x
Reference in New Issue
Block a user