From d7f12b083ee9901c5e5a95170559376d51b00f20 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Oct 2023 12:47:48 +0400 Subject: [PATCH] Always make custom emoji most-inner tag. --- ui/text/text_entity.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/text/text_entity.cpp b/ui/text/text_entity.cpp index 5adfe7c..383b3d0 100644 --- a/ui/text/text_entity.cpp +++ b/ui/text/text_entity.cpp @@ -2111,14 +2111,11 @@ EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags) { closeType(type); } } - if (linkChanged && !nextState.link.isEmpty()) { - if (Ui::InputField::IsCustomEmojiLink(nextState.link)) { - const auto data = Ui::InputField::CustomEmojiEntityData( - nextState.link); - if (!data.isEmpty()) { - openType(EntityType::CustomEmoji, data); - } - } else if (IsMentionLink(nextState.link)) { + const auto openLink = linkChanged && !nextState.link.isEmpty(); + const auto openCustomEmoji = openLink + && Ui::InputField::IsCustomEmojiLink(nextState.link); + if (openLink && !openCustomEmoji) { + if (IsMentionLink(nextState.link)) { const auto data = MentionEntityData(nextState.link); if (!data.isEmpty()) { openType(EntityType::MentionName, data); @@ -2132,6 +2129,13 @@ EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags) { openType(type, nextState.language); } } + if (openCustomEmoji) { + const auto data = Ui::InputField::CustomEmojiEntityData( + nextState.link); + if (!data.isEmpty()) { + openType(EntityType::CustomEmoji, data); + } + } state = nextState; }; const auto stateForTag = [&](const QString &tag) {