From 67079545b36af3b1a44ef7d2adfcf35cdaf203e9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 4 Aug 2025 11:15:09 +0400 Subject: [PATCH] Ease filtering on posts search queries. --- Telegram/SourceFiles/dialogs/dialogs_search_posts.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_search_posts.cpp b/Telegram/SourceFiles/dialogs/dialogs_search_posts.cpp index 011c252b10..f6ea385258 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_search_posts.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_search_posts.cpp @@ -20,6 +20,12 @@ namespace { constexpr auto kQueryDelay = crl::time(500); constexpr auto kPerPage = 50; +[[nodiscard]] const QRegularExpression &SearchSplitter() { + static const auto result = QRegularExpression(QString::fromLatin1("" + "[\\@\\s\\-\\+\\(\\)\\[\\]\\{\\}\\<\\>\\,\\.\\!\\_\\;\\\"\\'\\x0]")); + return result; +} + } // namespace PostsSearch::PostsSearch(not_null session) @@ -58,7 +64,9 @@ void PostsSearch::requestMore() { } void PostsSearch::setQuery(const QString &query) { - const auto words = TextUtilities::PrepareSearchWords(query); + const auto words = TextUtilities::PrepareSearchWords( + query, + &SearchSplitter()); const auto prepared = words.isEmpty() ? QString() : words.join(' '); if (_queryExact == query) { return;