Bring chosen font to the top of the box.

This commit is contained in:
John Preston 2024-05-08 17:16:34 +04:00
parent b5f5aed119
commit 1f31d8032f

View file

@ -546,15 +546,25 @@ std::vector<Selector::Entry> Selector::FullList(const QString &now) {
result.push_back({ .id = family });
}
}
if (!ranges::contains(result, now, &Entry::id)) {
auto nowIt = ranges::find(result, now, &Entry::id);
if (nowIt == end(result)) {
result.push_back({ .id = now });
nowIt = end(result) - 1;
}
for (auto i = begin(result) + 2; i != end(result); ++i) {
i->key = TextUtilities::RemoveAccents(i->id).toLower();
i->text = i->id;
i->keywords = TextUtilities::PrepareSearchWords(i->id);
}
ranges::sort(begin(result) + 2, end(result), std::less<>(), &Entry::key);
auto skip = 2;
if (nowIt - begin(result) >= skip) {
std::swap(result[2], *nowIt);
++skip;
}
ranges::sort(
begin(result) + skip, end(result),
std::less<>(),
&Entry::key);
return result;
}