mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix surrogatepairs messing position of emotes to be removed (mismatch
between actual position, and position in unicode codepoints)
This commit is contained in:
parent
9472283d76
commit
27eb2d8abc
1 changed files with 10 additions and 1 deletions
|
@ -183,9 +183,18 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
const auto &phrases = app->ignores->phrases.getVector();
|
const auto &phrases = app->ignores->phrases.getVector();
|
||||||
auto removeEmotesInRange =
|
auto removeEmotesInRange =
|
||||||
[](int pos, int len,
|
[&message = this->originalMessage_](int pos, int len,
|
||||||
std::vector<std::tuple<int, EmotePtr, EmoteName>>
|
std::vector<std::tuple<int, EmotePtr, EmoteName>>
|
||||||
&twitchEmotes) mutable {
|
&twitchEmotes) mutable {
|
||||||
|
int emotePos = 0;
|
||||||
|
for(int i = 0; i < pos; ++i) {
|
||||||
|
++emotePos;
|
||||||
|
if (message.at(i).isLowSurrogate()) {
|
||||||
|
--emotePos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pos = emotePos;
|
||||||
|
|
||||||
auto it =
|
auto it =
|
||||||
std::partition(twitchEmotes.begin(), twitchEmotes.end(),
|
std::partition(twitchEmotes.begin(), twitchEmotes.end(),
|
||||||
[pos, len](const auto &item) {
|
[pos, len](const auto &item) {
|
||||||
|
|
Loading…
Reference in a new issue