Skip to content

Commit

Permalink
added equality operator as suggested by @hypest and a comment explain…
Browse files Browse the repository at this point in the history
…ing the added safeguard check
  • Loading branch information
mzorz committed Apr 5, 2019
1 parent 2cb8891 commit 7b8955a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ private void updateSelectionIfNeeded(ReactAztecText view, @Nullable ReadableMap
if ( selection != null ) {
int start = selection.getInt("start");
int end = selection.getInt("end");
if (view.getText().length() > end && start >= 0) {
// let's make sure the selection is within a valid range
// otherwise we'd crash here - first observed with lists
// and undo/redo states as expressed in
// https://github.com/wordpress-mobile/gutenberg-mobile/issues/208#issuecomment-480246421
if (view.getText().length() >= end && start >= 0) {
view.setSelection(start, end);
}
}
Expand Down

0 comments on commit 7b8955a

Please sign in to comment.