From 72f690ce99f519ee24de6141029b8cac8bf2f92b Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 24 Feb 2026 17:17:38 +0400 Subject: [PATCH] Fix formatted date quotes. --- Telegram/SourceFiles/api/api_text_entities.cpp | 3 ++- .../history/view/history_view_element.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/api/api_text_entities.cpp b/Telegram/SourceFiles/api/api_text_entities.cpp index 3f26b832a8..8db97edf0c 100644 --- a/Telegram/SourceFiles/api/api_text_entities.cpp +++ b/Telegram/SourceFiles/api/api_text_entities.cpp @@ -291,7 +291,8 @@ MTPVector EntitiesToMTP( && entity.type() != EntityType::Spoiler && entity.type() != EntityType::MentionName && entity.type() != EntityType::CustomUrl - && entity.type() != EntityType::CustomEmoji) { + && entity.type() != EntityType::CustomEmoji + && entity.type() != EntityType::FormattedDate) { continue; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index edf0e3f692..7488aeb06c 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -450,7 +450,7 @@ int KeyboardStyle::minButtonWidth( int(modification.skipped), result.to - modification.position); result.to -= shiftTo; - if (modification.position <= result.from) { + if (modification.position < result.from) { if (modification.added) { result.from += modification.added; } @@ -458,6 +458,10 @@ int KeyboardStyle::minButtonWidth( int(modification.skipped), result.from - modification.position); result.from -= shiftFrom; + } else if (modification.position == result.from) { + if (!modification.skipped) { + result.from += modification.added; + } } } return result; @@ -2667,14 +2671,17 @@ SelectedQuote Element::FindSelectedQuote( for (const auto &modification : text.modifications()) { if (modification.position >= selection.to) { break; - } else if (modification.position <= selection.from) { + } else if (modification.position < selection.from) { modified.from += modification.skipped; - if (modification.added - && modification.position < selection.from) { + if (modification.added) { modified.from = uint16(std::max( 0, int(modified.from) - int(modification.added))); } + } else if (modification.position == selection.from) { + if (!modification.added) { + modified.from += modification.skipped; + } } modified.to += modification.skipped; if (modification.added && modified.to > modified.from) { @@ -2703,6 +2710,7 @@ SelectedQuote Element::FindSelectedQuote( EntityType::StrikeOut, EntityType::Spoiler, EntityType::CustomEmoji, + EntityType::FormattedDate, }; for (auto i = result.entities.begin(); i != result.entities.end();) { const auto offset = i->offset();