From 937e33a2fd6f1c652a8299c3e9518dce214c82d2 Mon Sep 17 00:00:00 2001 From: Adam Davies <8650006+acdvs@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:49:08 -0600 Subject: [PATCH] Fix zero-width emotes sometimes wrapping lines incorrectly (#3389) Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada --- CHANGELOG.md | 1 + src/messages/layouts/MessageLayoutContainer.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 498aec9a..ba5611f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ - Bugfix: Fixed IRC highlights not triggering sounds or alerts properly. (#3368) - Bugfix: Fixed IRC /kick command crashing if parameters were malformed. (#3382) - Bugfix: Fixed a crash that could occur on certain Linux systems when toggling the Always on Top flag. (#3385) +- Bugfix: Fixed zero-width emotes sometimes wrapping lines incorrectly. (#3389) - Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index 66e53306..5fca4008 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -65,7 +65,10 @@ void MessageLayoutContainer::clear() void MessageLayoutContainer::addElement(MessageLayoutElement *element) { - if (!this->fitsInLine(element->getRect().width())) + bool isZeroWidth = + element->getFlags().has(MessageElementFlag::ZeroWidthEmote); + + if (!isZeroWidth && !this->fitsInLine(element->getRect().width())) { this->breakLine(); }