diff options
author | George Hazan <george.hazan@gmail.com> | 2025-03-19 21:55:20 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-03-19 21:55:20 +0300 |
commit | 3fe39e22a61394e523932cd9276305428b6bdf80 (patch) | |
tree | 8cae111a7ab2e1e71f923a4cb56b54c56044d971 /protocols/Telegram/src/utils.cpp | |
parent | 1c9c61389c26db5f2aecea142af05894d9f18601 (diff) |
fixes #4908 completely
Diffstat (limited to 'protocols/Telegram/src/utils.cpp')
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index c266b9dd55..3c3b68ebb1 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -116,15 +116,18 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr<TD::formattedText> &pT int off1 = 0, off2 = 0;
for (auto &h : history) {
if (it->offset_ >= h.start)
- off1 += h.bbcode.len1, off2 += h.bbcode.len1;
-
+ off1 += h.bbcode.len1;
+ if (it->offset_ + it->length_ > h.start)
+ off2 += h.bbcode.len1;
+ if (it->offset_ >= h.start + h.length)
+ off1 += h.bbcode.len2;
if (it->offset_ + it->length_ > h.start + h.length)
off2 += h.bbcode.len2;
}
auto &bb = bbCodes[iCode];
- ret.Insert(off1 + it->offset_ + it->length_, bb.end);
- ret.Insert(off2 + it->offset_, bb.begin);
+ ret.Insert(off2 + it->offset_ + it->length_, bb.end);
+ ret.Insert(off1 + it->offset_, bb.begin);
history.push_back(HistItem(it->offset_, it->length_, bb));
}
return T2Utf(ret).get();
|