Skip to content

Commit

Permalink
fixes acejump#315
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Nov 30, 2019
1 parent 650dde3 commit 26a27e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/org/acejump/search/Scanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import org.acejump.view.Model.viewBounds
*/

internal object Scanner {
fun findMatchingSites(editorText: String, model: AceFindModel, cache: Set<Int>) =
editorText.run {
fun findMatchingSites(searchText: String, model: AceFindModel, cache: Set<Int>) =
searchText.run {
val query = model.stringToFind
if (query.isEmpty()) return sortedSetOf<Int>()
// If the cache is populated, filter it instead of redoing prior work
if (cache.isEmpty()) findAll(model.toRegex(), boundaries.start)
else cache.asSequence().filter {
else cache.asSequence().filter { index ->
regionMatches(
thisOffset = it + query.length - 1,
thisOffset = index + query.length - 1,
other = query.last().toString(),
otherOffset = 0,
length = 1,
Expand Down

0 comments on commit 26a27e7

Please sign in to comment.