···108108 fractionOfDistanceBetweenInsertionPoints: nil
109109 )
110110111111- var lastUpperOffset: Int = 0
111111+ var lastUpperBound: String.Index? = nil
112112 for child in self.reactSubviews() {
113113 if let child = child as? RNUITextViewChild, let childText = child.text {
114114 let fullText = self.textView.attributedText.string
···116116 // We want to skip over the children we have already checked, otherwise we could run into
117117 // collisions of similar strings (i.e. links that get shortened to the same hostname but
118118 // different paths)
119119- let startIndex = fullText.index(fullText.startIndex, offsetBy: lastUpperOffset)
120120- let range = fullText.range(of: childText, options: [], range: startIndex..<fullText.endIndex)
119119+ let range = fullText.range(of: childText, options: [], range: (lastUpperBound ?? String.Index(utf16Offset: 0, in: fullText) )..<fullText.endIndex)
121120122121 if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound {
123122 let lowerOffset = lowerBound.utf16Offset(in: fullText)
···128127 {
129128 return child
130129 } else {
131131- lastUpperOffset = upperOffset
130130+ lastUpperBound = upperBound
132131 }
133132 }
134133 }