Do not try to apply selections outside the length of the text (flutter/engine#3845)

See https://github.com/flutter/flutter/issues/11041
This commit is contained in:
Jason Simmons
2017-06-30 14:50:01 -07:00
committed by GitHub
parent 5d12e39001
commit 49102a88dd

View File

@@ -137,7 +137,8 @@ public class TextInputPlugin implements MethodCallHandler {
private void applyStateToSelection(JSONObject state) throws JSONException {
int selStart = state.getInt("selectionBase");
int selEnd = state.getInt("selectionExtent");
if (selStart != -1 && selEnd != -1) {
if (selStart >= 0 && selStart <= mEditable.length() &&
selEnd >= 0 && selEnd <= mEditable.length()) {
Selection.setSelection(mEditable, selStart, selEnd);
} else {
Selection.removeSelection(mEditable);