             let index = indexInSortedCollection(lines) { line in
                 if byteOffset < line.byteRange.location {
                     return .orderedAscending
-                }
-                else if byteOffset >= line.byteRange.location + line.byteRange.length {
+                } else if byteOffset >= line.byteRange.location + line.byteRange.length {
                     return .orderedDescending
                 }
                 return .orderedSame

            let index = indexInSortedCollection(lines) { line in
                if location < line.range.location {
                    return .orderedAscending
                }
                else if location >= line.range.location + line.range.length {
                    return .orderedDescending
                }
                return .orderedSame

    return characterSet
}()

private func indexInSortedCollection<C>(_ collection: C,
                                        comparing: (C.Element) throws -> ComparisonResult) rethrows -> C.Index? where C: RandomAccessCollection {
    guard !collection.isEmpty else {
        return nil
    }

    var lowerBound = collection.startIndex
    var upperBound = collection.index(before: collection.endIndex)
    var midIndex: C.Index

    while lowerBound <= upperBound {
        let distance = collection.distance(from: lowerBound, to: upperBound)
        midIndex = collection.index(lowerBound, offsetBy: distance / 2)
        let midElem = collection[midIndex]

        switch try comparing(midElem) {
        case .orderedDescending: lowerBound = collection.index(midIndex, offsetBy: 1)
        case .orderedAscending: upperBound = collection.index(midIndex, offsetBy: -1)
        case .orderedSame: return midIndex
        }
    }

    return nil
}

extension NSString {
    /**
