Fix crash when searching from end of file.

This commit is contained in:
TrianguloY 2019-04-09 23:00:08 +02:00
parent 4b0d443d10
commit 5b715fc6b4

View file

@ -75,8 +75,9 @@ public class Search {
Matcher matcher = pattern.matcher(text); Matcher matcher = pattern.matcher(text);
if(!mChkBackwards.isChecked()) { if(!mChkBackwards.isChecked()) {
// search fordwards // search fordwards
int from = mEditText.getSelectionStart();
if( matcher.find(mEditText.getSelectionStart() + 1) || matcher.find(0)){ if (from != mEditText.getSelectionEnd()) from++; // avoids returning the current selection
if( matcher.find(from) || matcher.find(0)){
// found one just after the selection or from the beginning // found one just after the selection or from the beginning
start = matcher.start(); start = matcher.start();
end = matcher.end(); end = matcher.end();