Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential StringIndexOutOfBoundsException, fixes #1020 #1023

Merged
merged 1 commit into from
Mar 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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