From 5b715fc6b466a028d1db451d0dd7061139c2e98c Mon Sep 17 00:00:00 2001 From: TrianguloY Date: Tue, 9 Apr 2019 23:00:08 +0200 Subject: [PATCH] Fix crash when searching from end of file. --- .../java/net/pierrox/lightning_launcher/util/Search.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/Search.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/Search.java index 85eea63..bfb1b2f 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/Search.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/Search.java @@ -75,8 +75,9 @@ public class Search { Matcher matcher = pattern.matcher(text); if(!mChkBackwards.isChecked()) { // search fordwards - - if( matcher.find(mEditText.getSelectionStart() + 1) || matcher.find(0)){ + int from = mEditText.getSelectionStart(); + 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 start = matcher.start(); end = matcher.end();