From 5112ec73b01f5d93d3f39004f70d05a564f1ae64 Mon Sep 17 00:00:00 2001 From: Tal Neoran Date: Sun, 24 Oct 2021 15:30:28 +0300 Subject: [PATCH] Fix zero-width emotes alignment with removeSpacesBetweenEmotes setting (#3249) Co-authored-by: pajlada --- CHANGELOG.md | 1 + src/messages/layouts/MessageLayoutContainer.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb22a2c3..55e86861d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Bugfix: Fixed own IRC messages not having metadata and a link to a usercard. (#3203) - Bugfix: Fixed some channels still not loading in rare cases. (#3219) - Bugfix: Fixed a bug with usernames or emotes completing from the wrong position. (#3229) +- Bugfix: Fixed a bug that caused zero-width emotes to be misaligned when the "Remove spaces between emotes" setting is on. (#3249) - Bugfix: Fixed second chatterino icon appearing in the dock when restarting on a crash in macOS. (#3268) - Bugfix: Fixed the "Change channel" popup showing a wrong window title (#3273) - Bugfix: Fixed built-in Chatterino commands not working in whispers and mentions special channels (#3288) diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index c4cc4fa02..66e533069 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -147,9 +147,10 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element, this->lineHeight_ = std::max(this->lineHeight_, newLineHeight); auto xOffset = 0; + bool isZeroWidthEmote = element->getCreator().getFlags().has( + MessageElementFlag::ZeroWidthEmote); - if (element->getCreator().getFlags().has( - MessageElementFlag::ZeroWidthEmote)) + if (isZeroWidthEmote) { xOffset -= element->getRect().width() + this->spaceWidth_; } @@ -166,7 +167,7 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element, if (getSettings()->removeSpacesBetweenEmotes && element->getFlags().hasAny({MessageElementFlag::EmoteImages}) && - shouldRemoveSpaceBetweenEmotes()) + !isZeroWidthEmote && shouldRemoveSpaceBetweenEmotes()) { // Move cursor one 'space width' to the left to combine hug the previous emote this->currentX_ -= this->spaceWidth_; @@ -183,8 +184,7 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element, this->elements_.push_back(std::unique_ptr(element)); // set current x - if (!element->getCreator().getFlags().has( - MessageElementFlag::ZeroWidthEmote)) + if (!isZeroWidthEmote) { this->currentX_ += element->getRect().width(); }