From f9a4266e2ffd49e38d2d9bb536cd6af5009c4868 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 5 Oct 2023 18:30:34 +0200 Subject: SL-20355 Sort completion suggestions by position of the search pattern --- indra/llui/llemojidictionary.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llui/llemojidictionary.cpp b/indra/llui/llemojidictionary.cpp index bf7e53701d..e29f3436cf 100644 --- a/indra/llui/llemojidictionary.cpp +++ b/indra/llui/llemojidictionary.cpp @@ -192,6 +192,8 @@ void LLEmojiDictionary::findByShortCode(std::vector& result return false; }; + std::map> results; + for (const LLEmojiDescriptor& d : mEmojis) { if (d.ShortCodes.empty()) @@ -202,9 +204,18 @@ void LLEmojiDictionary::findByShortCode(std::vector& result std::size_t begin, end; if (search(begin, end, shortCode)) { - result.emplace_back(d.Character, shortCode, begin, end); + results[begin].emplace_back(d.Character, shortCode, begin, end); } } + + for (const auto& it : results) + { +#ifdef __cpp_lib_containers_ranges + result.append_range(it.second); +#else + result.insert(result.end(), it.second.cbegin(), it.second.cend()); +#endif + } } const LLEmojiDescriptor* LLEmojiDictionary::getDescriptorFromEmoji(llwchar emoji) const -- cgit v1.2.3