diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2023-10-05 18:30:34 +0200 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2023-10-05 18:41:01 +0200 |
commit | f9a4266e2ffd49e38d2d9bb536cd6af5009c4868 (patch) | |
tree | 081a7fee70500bbf38796e131d43da7861de70ba | |
parent | da783d1750ec8a03d62ddf81a0b44bba1b2f565b (diff) |
SL-20355 Sort completion suggestions by position of the search pattern
-rw-r--r-- | indra/llui/llemojidictionary.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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<LLEmojiSearchResult>& result return false; }; + std::map<std::size_t, std::vector<LLEmojiSearchResult>> results; + for (const LLEmojiDescriptor& d : mEmojis) { if (d.ShortCodes.empty()) @@ -202,9 +204,18 @@ void LLEmojiDictionary::findByShortCode(std::vector<LLEmojiSearchResult>& 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 |