Make sure we don't use negative oftsets when finding an index. Fixes #3204
This commit is contained in:
parent
2862d40663
commit
17cc23364d
|
@ -91,8 +91,8 @@ private extension TwitterStatus {
|
|||
}
|
||||
}
|
||||
|
||||
let offsetStartIndex = entity.startIndex - unicodeScalarOffset
|
||||
let offsetEndIndex = entity.endIndex - unicodeScalarOffset
|
||||
let offsetStartIndex = unicodeScalarOffset < entity.startIndex ? entity.startIndex - unicodeScalarOffset : entity.startIndex
|
||||
let offsetEndIndex = unicodeScalarOffset < entity.endIndex ? entity.endIndex - unicodeScalarOffset : entity.endIndex
|
||||
|
||||
let entityStartIndex = text.index(text.startIndex, offsetBy: offsetStartIndex, limitedBy: text.endIndex) ?? text.startIndex
|
||||
let entityEndIndex = text.index(text.startIndex, offsetBy: offsetEndIndex, limitedBy: text.endIndex) ?? text.endIndex
|
||||
|
|
Loading…
Reference in New Issue