Fix zero-width emotes alignment with removeSpacesBetweenEmotes setting (#3249)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Tal Neoran 2021-10-24 15:30:28 +03:00 committed by GitHub
parent 50b02f099a
commit 5112ec73b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -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)

View file

@ -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<MessageLayoutElement>(element));
// set current x
if (!element->getCreator().getFlags().has(
MessageElementFlag::ZeroWidthEmote))
if (!isZeroWidthEmote)
{
this->currentX_ += element->getRect().width();
}