Update string attribute range clipping

This commit is contained in:
Ali
2022-12-08 17:20:18 +04:00
parent 94ccf7ed3b
commit 71bed257bb
2 changed files with 21 additions and 2 deletions

View File

@@ -18,8 +18,10 @@ public func chatInputStateStringWithAppliedEntities(_ text: String, entities: [M
if nsString == nil {
nsString = text as NSString
}
if range.location >= stringLength {
continue
}
if range.location + range.length > stringLength {
range.location = max(0, stringLength - range.length)
range.length = stringLength - range.location
}
switch entity.type {
@@ -75,7 +77,6 @@ public func stringWithAppliedEntities(_ text: String, entities: [MessageTextEnti
if range.location > stringLength {
continue
} else if range.location + range.length > stringLength {
range.location = max(0, stringLength - range.length)
range.length = stringLength - range.location
}
switch entity.type {