summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-22 21:27:51 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-22 21:27:51 +0300
commitb23514fd642eb0a4f63a565ac1e6ae44902395fc (patch)
treeaf22de685e7b68eeef7f0df7a791ade91b5a14b9 /protocols/Telegram/src/utils.cpp
parent45a6b265a4b93103d79bd86120469fd24f09aeb2 (diff)
minor fix for receiving multiple bbCodes
Diffstat (limited to 'protocols/Telegram/src/utils.cpp')
-rw-r--r--protocols/Telegram/src/utils.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index b2a1c9c3eb..7212a04d1d 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -76,6 +76,8 @@ static CMStringA getFormattedText(TD::object_ptr<TD::formattedText> &pText)
{
if (pText->get_id() == TD::formattedText::ID) {
CMStringW ret(Utf2T(pText->text_.c_str()));
+ unsigned offset = 0;
+
for (auto &it : pText->entities_) {
int iCode;
switch (it->type_->get_id()) {
@@ -87,8 +89,10 @@ static CMStringA getFormattedText(TD::object_ptr<TD::formattedText> &pText)
continue;
}
- ret.Insert(it->offset_ + it->length_, bbCodes[iCode].end);
- ret.Insert(it->offset_, bbCodes[iCode].begin);
+ auto &bb = bbCodes[iCode];
+ ret.Insert(offset + it->offset_ + it->length_, bb.end);
+ ret.Insert(offset + it->offset_, bb.begin);
+ offset += bb.len1 + bb.len2;
}
return T2Utf(ret).get();
}