Skip to content

Commit e2f6f7f

Browse files
Merge branch 'refs/heads/main' into Recurring-tasks-WorkManager
2 parents 7e19557 + 279c224 commit e2f6f7f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ scripts/backup.ab
3939
# miscellaneous
4040
all-apks.sh
4141
device*.png
42+
43+
# Log Files
44+
*.log

app/src/main/java/org/wikipedia/edit/FindInEditorActionProvider.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.view.View
77
import org.wikipedia.edit.richtext.SyntaxHighlighter
88
import org.wikipedia.util.DeviceUtil
99
import org.wikipedia.util.DimenUtil
10-
import org.wikipedia.util.StringUtil
1110
import org.wikipedia.views.FindInPageActionProvider
1211
import org.wikipedia.views.FindInPageActionProvider.FindInPageListener
1312

@@ -62,10 +61,16 @@ class FindInEditorActionProvider(private val scrollView: View,
6261
searchQuery = text?.ifEmpty { null }
6362
currentResultIndex = 0
6463
resultPositions.clear()
65-
6664
searchQuery?.let { query ->
67-
resultPositions += query.toRegex(StringUtil.SEARCH_REGEX_OPTIONS).findAll(textView.text)
68-
.map { it.range.first }
65+
val textToSearch = textView.text
66+
var index = 0
67+
while (index >= 0 && index < textToSearch.length) {
68+
index = textToSearch.indexOf(query, index, ignoreCase = true)
69+
if (index >= 0) {
70+
resultPositions.add(index)
71+
index += query.length
72+
}
73+
}
6974
}
7075
scrollToCurrentResult()
7176
}

0 commit comments

Comments
 (0)