From 3fe39e22a61394e523932cd9276305428b6bdf80 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 19 Mar 2025 21:55:20 +0300 Subject: fixes #4908 completely --- protocols/Telegram/src/utils.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'protocols/Telegram/src/utils.cpp') 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 &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(); -- cgit v1.2.3