From 6f328b2ef8ad1d44c719426b9ca615afb2f4c0c8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 22 Apr 2024 15:06:48 +0400 Subject: [PATCH] Fix inline query draft applying. --- Telegram/SourceFiles/data/data_drafts.cpp | 9 ++++++--- Telegram/SourceFiles/data/data_drafts.h | 4 +--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/data/data_drafts.cpp b/Telegram/SourceFiles/data/data_drafts.cpp index e0ebb7741..1bd7135e8 100644 --- a/Telegram/SourceFiles/data/data_drafts.cpp +++ b/Telegram/SourceFiles/data/data_drafts.cpp @@ -129,9 +129,12 @@ void ClearPeerCloudDraft( history->applyCloudDraft(topicRootId); } -void SetChatLinkDraft( - not_null peer, - const TextWithEntities &draft) { +void SetChatLinkDraft(not_null peer, TextWithEntities draft) { + static const auto kInlineStart = QRegularExpression("^@[a-zA-Z0-9_]"); + if (kInlineStart.match(draft.text).hasMatch()) { + draft = TextWithEntities().append(' ').append(std::move(draft)); + } + const auto textWithTags = TextWithTags{ draft.text, TextUtilities::ConvertEntitiesToTextTags(draft.entities) diff --git a/Telegram/SourceFiles/data/data_drafts.h b/Telegram/SourceFiles/data/data_drafts.h index 581acaeea..1330995ed 100644 --- a/Telegram/SourceFiles/data/data_drafts.h +++ b/Telegram/SourceFiles/data/data_drafts.h @@ -205,8 +205,6 @@ using HistoryDrafts = base::flat_map>; && (a->webpage == b->webpage); } -void SetChatLinkDraft( - not_null peer, - const TextWithEntities &draft); +void SetChatLinkDraft(not_null peer, TextWithEntities draft); } // namespace Data