krisk / fuse-swift

A lightweight fuzzy-search library, with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fatal error: Can't form Range with upperBound < lowerBound

el-quick opened this issue · comments

I am trying use asynchronous version on this way:

fuse.search(searchText, in: Keyword.searchables, completion: { results in
    ...
})

And I am getting this problem:

Captura de Pantalla 2019-12-17 a la(s) 09 32 21

To take in account: Keyword.searchables is an array of string with near of 3000 items in it.

By the moment I solved it on this way:

for (index, item) in chunk.enumerated() {
    if let result = self.search(pattern, in: item) {
        if result.ranges.allSatisfy({ $0.upperBound > $0.lowerBound }) {
            items.append((index, result.score, result.ranges))
        }
    }
}

I know that's not the best way, and functionality comes affected, but it's working for me now.

Thanks in advance.