From 252bf3e363f54860f2ca23d7dec71a9db050c7a7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 20 Apr 2026 08:31:47 +0300 Subject: [PATCH] Improved search of emoji from emoji list widget. --- .../SourceFiles/chat_helpers/emoji_list_widget.cpp | 11 ++++++----- .../SourceFiles/chat_helpers/stickers_list_footer.cpp | 5 +++-- .../SourceFiles/chat_helpers/stickers_list_footer.h | 3 ++- Telegram/SourceFiles/ui/controls/tabbed_search.cpp | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 3957bd2e75..a777157679 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -670,12 +670,13 @@ void EmojiListWidget::applyNextSearchQuery() { } const auto guard = gsl::finally([&] { finish(); }); auto plain = collectPlainSearchResults(); - if (_searchEmoji == _searchEmojiPrevious) { - return; - } _searchEmoticon = QString(); - for (const auto emoji : plain) { - _searchEmoticon += emoji->text(); + { + auto exactSet = base::flat_set(); + const auto exact = SearchEmoji(_searchQuery, exactSet, true); + for (const auto emoji : exact) { + _searchEmoticon += emoji->text(); + } } _searchResults.clear(); _searchCustomIds.clear(); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp index a0394d1ade..8971ceec58 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp @@ -146,7 +146,8 @@ rpl::producer> GifSectionsValue( [[nodiscard]] std::vector SearchEmoji( const std::vector &query, - base::flat_set &outResultSet) { + base::flat_set &outResultSet, + bool exact) { auto result = std::vector(); const auto pushPlain = [&](EmojiPtr emoji) { if (result.size() < kEmojiSearchLimit @@ -170,7 +171,7 @@ rpl::producer> GifSectionsValue( refreshed = true; keywords.refresh(); } - const auto list = keywords.queryMine(entry); + const auto list = keywords.queryMine(entry, exact); for (const auto &entry : list) { pushPlain(entry.emoji); if (result.size() >= kEmojiSearchLimit) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.h b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.h index a76b1ee21a..e5910d60c4 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.h @@ -70,7 +70,8 @@ struct GifSection { [[nodiscard]] std::vector SearchEmoji( const std::vector &query, - base::flat_set &outResultSet); + base::flat_set &outResultSet, + bool exact = false); struct StickerIcon { explicit StickerIcon(uint64 setId); diff --git a/Telegram/SourceFiles/ui/controls/tabbed_search.cpp b/Telegram/SourceFiles/ui/controls/tabbed_search.cpp index 55b9edd481..d806e7a390 100644 --- a/Telegram/SourceFiles/ui/controls/tabbed_search.cpp +++ b/Telegram/SourceFiles/ui/controls/tabbed_search.cpp @@ -80,7 +80,7 @@ private: }; [[nodiscard]] std::vector FieldQuery(not_null field) { - if (const auto last = field->getLastText(); !last.isEmpty()) { + if (const auto last = field->getLastText().trimmed(); !last.isEmpty()) { return { last }; } return {};