1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 07:13:24 +03:00

GH-227 Tidy up

This commit is contained in:
Tae Won Ha 2016-09-25 18:53:46 +02:00
parent 27cb880781
commit 18985c9785
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -60,7 +60,8 @@ class Matcher {
/// Matches `pattern` to `target` in a fuzzy way. /// Matches `pattern` to `target` in a fuzzy way.
/// - returns: `Array` of `Range<String.UnicodeScalarIndex>` /// - returns: `Array` of `Range<String.UnicodeScalarIndex>`
static func fuzzyIgnoringCase(_ target: String, pattern: String) -> (matches: Int, ranges: [CountableRange<Int>]) { static func fuzzyIgnoringCase(_ target: String,
pattern: String) -> (matches: Int, ranges: [CountableClosedRange<Int>]) {
let tlower = target.lowercased() let tlower = target.lowercased()
let plower = pattern.lowercased() let plower = pattern.lowercased()
@ -77,7 +78,7 @@ class Matcher {
} }
} }
var ranges: [CountableRange<Int>] = [] var ranges: [CountableClosedRange<Int>] = []
var matches = 0 var matches = 0
var lastTrue = -1 var lastTrue = -1
@ -93,14 +94,14 @@ class Matcher {
if i == flags.count &- 1 { if i == flags.count &- 1 {
if lastTrue > -1 && curTrue > -1 { if lastTrue > -1 && curTrue > -1 {
ranges.append(CountableRange(lastTrue...curTrue)) ranges.append(lastTrue...curTrue)
lastTrue = -1 lastTrue = -1
curTrue = -1 curTrue = -1
} }
} }
} else { } else {
if lastTrue > -1 && curTrue > -1 { if lastTrue > -1 && curTrue > -1 {
ranges.append(CountableRange(lastTrue...curTrue)) ranges.append(lastTrue...curTrue)
lastTrue = -1 lastTrue = -1
curTrue = -1 curTrue = -1
} }