mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge quotes before sending
This commit is contained in:
parent
37e861817b
commit
333011a6a6
2 changed files with 31 additions and 2 deletions
|
|
@ -181,6 +181,35 @@ public func generateChatInputTextEntities(_ text: NSAttributedString, maxAnimate
|
|||
}
|
||||
}
|
||||
|
||||
while true {
|
||||
var hadReductions = false
|
||||
|
||||
scan: for i in 0 ..< entities.count {
|
||||
if case .BlockQuote = entities[i].type {
|
||||
inner: for j in 0 ..< entities.count {
|
||||
if j == i {
|
||||
continue inner
|
||||
}
|
||||
if case .BlockQuote = entities[j].type {
|
||||
if entities[i].range.upperBound == entities[j].range.lowerBound || entities[i].range.lowerBound == entities[j].range.upperBound {
|
||||
entities[i].range = min(entities[i].range.lowerBound, entities[j].range.lowerBound) ..< max(entities[i].range.upperBound, entities[j].range.upperBound)
|
||||
entities.remove(at: j)
|
||||
|
||||
hadReductions = true
|
||||
break scan
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break scan
|
||||
}
|
||||
}
|
||||
|
||||
if !hadReductions {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return entities
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue