Skip to content

Commit

Permalink
Fix potential StringIndexOutOfBoundsException, fixes #1020 (#1023)
Browse files Browse the repository at this point in the history
At present it's still unclear under which condition this issue was
triggered. It should no longer crash though, the UI might just behave a
bit strangely instead.
  • Loading branch information
dmfs authored Mar 21, 2021
1 parent f5ad4ae commit 71af1e5
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,10 @@ private void bindItemView(final View itemView, final DescriptionItem item)
return true;
}
// split current
int sel = text.getSelectionStart();
String newText = text.getText().toString().substring(sel);
item.text = text.getText().toString().substring(0, sel);
String current = text.getText().toString();
int sel = Math.max(0, Math.min(current.length(), text.getSelectionStart()));
String newText = current.substring(sel);
item.text = current.substring(0, sel);
text.setText(item.text);
text.clearFocus();
// create new item with new test
Expand Down

0 comments on commit 71af1e5

Please sign in to comment.