Commit 03141c2c authored by Matt Perry's avatar Matt Perry

Use engine's getWordBoundary method when user selects a word. (#3851)

parent 616d9e2e
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment