Make sure we don't use negative oftsets when finding an index. Fixes #3204
This commit is contained in:
parent
b549293167
commit
100823e57e
@ -91,8 +91,8 @@ private extension TwitterStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let offsetStartIndex = entity.startIndex - unicodeScalarOffset
|
let offsetStartIndex = unicodeScalarOffset < entity.startIndex ? entity.startIndex - unicodeScalarOffset : entity.startIndex
|
||||||
let offsetEndIndex = entity.endIndex - unicodeScalarOffset
|
let offsetEndIndex = unicodeScalarOffset < entity.endIndex ? entity.endIndex - unicodeScalarOffset : entity.endIndex
|
||||||
|
|
||||||
let entityStartIndex = text.index(text.startIndex, offsetBy: offsetStartIndex, limitedBy: text.endIndex) ?? text.startIndex
|
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
|
let entityEndIndex = text.index(text.startIndex, offsetBy: offsetEndIndex, limitedBy: text.endIndex) ?? text.endIndex
|
||||||
|
Loading…
x
Reference in New Issue
Block a user