Skip to content

Commit

Permalink
Do not pass negative selection indexes to InputConnection.setSelection (
Browse files Browse the repository at this point in the history
flutter#3344)

This was causing exceptions on Jellybean
  • Loading branch information
jason-simmons authored Jan 18, 2017
1 parent 81d8973 commit e573c6b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ public InputConnection createInputConnection(FlutterView view, EditorInfo outAtt
outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN;
InputConnectionAdaptor connection = new InputConnectionAdaptor(view, mClient, this);
if (mLatestState != null) {
outAttrs.initialSelStart = mLatestState.getInt("selectionBase");
outAttrs.initialSelEnd = mLatestState.getInt("selectionExtent");
int selectionBase = mLatestState.getInt("selectionBase");
int selectionExtent = mLatestState.getInt("selectionExtent");
outAttrs.initialSelStart = selectionBase;
outAttrs.initialSelEnd = selectionExtent;
connection.getEditable().append(mLatestState.getString("text"));
connection.setSelection(mLatestState.getInt("selectionBase"),
mLatestState.getInt("selectionExtent"));
connection.setSelection(Math.max(selectionBase, 0),
Math.max(selectionExtent, 0));
connection.setComposingRegion(mLatestState.getInt("composingBase"),
mLatestState.getInt("composingExtent"));
} else {
Expand Down

0 comments on commit e573c6b

Please sign in to comment.