From a28008969371a5ef7a078a1b72124180eec6d081 Mon Sep 17 00:00:00 2001 From: James Upjohn Date: Sun, 31 Jul 2022 21:55:25 +1200 Subject: [PATCH] Drop trailing whitespace from Twitch system messages (#3888) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/messages/MessageBuilder.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69f56955..40e01bf44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Bugfix: Adopt popup windows in order to force floating behavior on some window managers. (#3836) - Bugfix: Fix split focusing being broken in certain circumstances when the "Show input when it's empty" setting was disabled. (#3838, #3860) - Bugfix: Always refresh tab when a contained split's channel is set. (#3849) +- Bugfix: Drop trailing whitespace from Twitch system messages. (#3888) - Dev: Remove official support for QMake. (#3839, #3883) - Dev: Rewrite LimitedQueue (#3798) - Dev: Overhaul highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801, #3835) diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp index c34fd3b85..c74615b45 100644 --- a/src/messages/MessageBuilder.cpp +++ b/src/messages/MessageBuilder.cpp @@ -12,6 +12,7 @@ #include "singletons/Resources.hpp" #include "singletons/Theme.hpp" #include "util/FormatTime.hpp" +#include "util/Qt.hpp" #include @@ -185,19 +186,19 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text, // check system message for links // (e.g. needed for sub ticket message in sub only mode) - const QStringList textFragments = text.split(QRegularExpression("\\s")); + const QStringList textFragments = + text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts); for (const auto &word : textFragments) { const auto linkString = this->matchLink(word); - if (linkString.isEmpty()) - { - this->emplace(word, MessageElementFlag::Text, - MessageColor::System); - } - else + if (!linkString.isEmpty()) { this->addLink(word, linkString); + continue; } + + this->emplace(word, MessageElementFlag::Text, + MessageColor::System); } this->message().flags.set(MessageFlag::System); this->message().flags.set(MessageFlag::DoNotTriggerNotification);