From 49102a88dd971f674cd2b80a818fcff4c532a953 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 30 Jun 2017 14:50:01 -0700 Subject: [PATCH] Do not try to apply selections outside the length of the text (flutter/engine#3845) See https://github.com/flutter/flutter/issues/11041 --- .../android/io/flutter/plugin/editing/TextInputPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index eb20f6b1e4..8898b2b4c4 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -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);