From ee9b0f4c12879128b0ace22b463f996a9304f7cf Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 11 May 2019 14:00:16 +0200 Subject: [PATCH] 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 --- src/common/UsernameSet.cpp | 2 +- src/common/UsernameSet.hpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/UsernameSet.cpp b/src/common/UsernameSet.cpp index 8e0a53af7..d39b8a3e4 100644 --- a/src/common/UsernameSet.cpp +++ b/src/common/UsernameSet.cpp @@ -59,7 +59,7 @@ void UsernameSet::insertPrefix(const QString &value) { auto &string = this->firstKeyForPrefix[Prefix(value)]; - if (string.isNull() || value < string) + if (string.isNull() || value.compare(string, Qt::CaseInsensitive) < 0) string = value; } diff --git a/src/common/UsernameSet.hpp b/src/common/UsernameSet.hpp index 0d37f8851..f33d7d7e6 100644 --- a/src/common/UsernameSet.hpp +++ b/src/common/UsernameSet.hpp @@ -38,6 +38,13 @@ struct hash { namespace chatterino { +struct CaseInsensitiveLess { + bool operator()(const QString &lhs, const QString &rhs) const + { + return lhs.compare(rhs, Qt::CaseInsensitive) < 0; + } +}; + class UsernameSet { public: @@ -71,7 +78,7 @@ public: private: void insertPrefix(const QString &string); - std::set items; + std::set items; std::unordered_map firstKeyForPrefix; };