Fix tab completion

Fixes #813

This has the "quirk" of not updating names that are already there, which
means that display names might not always be used, instead the users
lowercase name might just be there and stick
This commit is contained in:
Rasmus Karlsson 2019-05-11 14:00:16 +02:00
parent 2492a0ba21
commit ee9b0f4c12
2 changed files with 9 additions and 2 deletions

View file

@ -59,7 +59,7 @@ void UsernameSet::insertPrefix(const QString &value)
{ {
auto &string = this->firstKeyForPrefix[Prefix(value)]; auto &string = this->firstKeyForPrefix[Prefix(value)];
if (string.isNull() || value < string) if (string.isNull() || value.compare(string, Qt::CaseInsensitive) < 0)
string = value; string = value;
} }

View file

@ -38,6 +38,13 @@ struct hash<chatterino::Prefix> {
namespace chatterino { namespace chatterino {
struct CaseInsensitiveLess {
bool operator()(const QString &lhs, const QString &rhs) const
{
return lhs.compare(rhs, Qt::CaseInsensitive) < 0;
}
};
class UsernameSet class UsernameSet
{ {
public: public:
@ -71,7 +78,7 @@ public:
private: private:
void insertPrefix(const QString &string); void insertPrefix(const QString &string);
std::set<QString> items; std::set<QString, CaseInsensitiveLess> items;
std::unordered_map<Prefix, QString> firstKeyForPrefix; std::unordered_map<Prefix, QString> firstKeyForPrefix;
}; };