mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
parent
010c061a25
commit
c382fdc528
|
@ -295,9 +295,12 @@ void EmoteManager::loadEmojis()
|
||||||
|
|
||||||
this->emojis.insert(code, util::EmoteData(new Image(url, 0.35, ":" + shortCode + ":",
|
this->emojis.insert(code, util::EmoteData(new Image(url, 0.35, ":" + shortCode + ":",
|
||||||
":" + shortCode + ":<br/>Emoji")));
|
":" + shortCode + ":<br/>Emoji")));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(pajlada): The vectors in emojiFirstByte need to be sorted by
|
for (auto &p : this->emojiFirstByte) {
|
||||||
// emojiData.code.length()
|
std::stable_sort(p.begin(), p.end(), [](const auto &lhs, const auto &rhs) {
|
||||||
|
return lhs.value.length() > rhs.value.length();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +309,7 @@ void EmoteManager::parseEmojis(std::vector<std::tuple<util::EmoteData, QString>>
|
||||||
{
|
{
|
||||||
int lastParsedEmojiEndIndex = 0;
|
int lastParsedEmojiEndIndex = 0;
|
||||||
|
|
||||||
for (auto i = 0; i < text.length() - 1; i++) {
|
for (auto i = 0; i < text.length(); ++i) {
|
||||||
const QChar character = text.at(i);
|
const QChar character = text.at(i);
|
||||||
|
|
||||||
if (character.isLowSurrogate()) {
|
if (character.isLowSurrogate()) {
|
||||||
|
@ -321,14 +324,15 @@ void EmoteManager::parseEmojis(std::vector<std::tuple<util::EmoteData, QString>>
|
||||||
|
|
||||||
const QVector<EmojiData> possibleEmojis = it.value();
|
const QVector<EmojiData> possibleEmojis = it.value();
|
||||||
|
|
||||||
int remainingCharacters = text.length() - i;
|
int remainingCharacters = text.length() - i - 1;
|
||||||
|
|
||||||
EmojiData matchedEmoji;
|
EmojiData matchedEmoji;
|
||||||
|
|
||||||
int matchedEmojiLength = 0;
|
int matchedEmojiLength = 0;
|
||||||
|
|
||||||
for (const EmojiData &emoji : possibleEmojis) {
|
for (const EmojiData &emoji : possibleEmojis) {
|
||||||
if (remainingCharacters < emoji.value.length()) {
|
int emojiExtraCharacters = emoji.value.length() - 1;
|
||||||
|
if (emojiExtraCharacters > remainingCharacters) {
|
||||||
// It cannot be this emoji, there's not enough space for it
|
// It cannot be this emoji, there's not enough space for it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue