提交 e5b79ba6 编写于 作者: J Jason Simmons 提交者: GitHub

Call Selection.removeSelection if the framework has cleared the selection (#3782)

Fixes https://github.com/flutter/flutter/issues/10748
上级 07d4357b
......@@ -131,11 +131,20 @@ public class TextInputPlugin implements MethodCallHandler {
mImm.restartInput(view);
}
private void applyStateToSelection(JSONObject state) throws JSONException {
int selStart = state.getInt("selectionBase");
int selEnd = state.getInt("selectionExtent");
if (selStart != -1 && selEnd != -1) {
Selection.setSelection(mEditable, selStart, selEnd);
} else {
Selection.removeSelection(mEditable);
}
}
private void setTextInputEditingState(FlutterView view, JSONObject state)
throws JSONException {
if (state.getString("text").equals(mEditable.toString())) {
Selection.setSelection(mEditable, state.getInt("selectionBase"),
state.getInt("selectionExtent"));
applyStateToSelection(state);
mImm.updateSelection(
mView,
Math.max(Selection.getSelectionStart(mEditable), 0),
......@@ -144,8 +153,7 @@ public class TextInputPlugin implements MethodCallHandler {
BaseInputConnection.getComposingSpanEnd(mEditable));
} else {
mEditable.replace(0, mEditable.length(), state.getString("text"));
Selection.setSelection(mEditable, state.getInt("selectionBase"),
state.getInt("selectionExtent"));
applyStateToSelection(state);
mImm.restartInput(view);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册