diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ea2344..890661ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Bugfix: Fixed scrolling now working on inputs in the settings. (#6128) - Bugfix: Make reply-cancel button less coarse-grained. (#6106) - Bugfix: Fixed missing BetterTTV live updates of emotes. (#6132) +- Bugfix: Fixed message contents being cleared when using the close button for replies. (#6145) - Bugfix: Handle CMD + BACKSPACE behavior explicitly in main chat dialog input for macOS. (#6111) - Bugfix: Fixed a small typo in the settings page. (#6134) - Bugfix: Fixed some Twitch commands not getting tab-completed correctly. (#6143) diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index c2013b44..2bc7c160 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -190,10 +190,10 @@ void SplitInput::initLayout() this->openEmotePopup(); }); - // clear input and remove reply target + // remove reply target QObject::connect(this->ui_.cancelReplyButton, &EffectLabel::leftClicked, [this] { - this->clearInput(); + this->setReply(nullptr); }); // Forward selection change signal @@ -1146,53 +1146,64 @@ void SplitInput::setReply(MessagePtr target) this->ui_.textEdit->resetCompletion(); } - assert(target != nullptr); - this->replyTarget_ = std::move(target); - - if (this->enableInlineReplying_) + if (target != nullptr) { - this->ui_.replyMessage->setWidth(this->replyMessageWidth()); - this->ui_.replyMessage->setMessage(this->replyTarget_); + this->replyTarget_ = std::move(target); - // add spacing between reply box and input box - this->ui_.vbox->setSpacing(this->marginForTheme()); - if (!this->isHidden()) + if (this->enableInlineReplying_) { - // update maximum height to give space for message - this->setMaximumHeight(this->scaledMaxHeight()); - } + this->ui_.replyMessage->setWidth(this->replyMessageWidth()); + this->ui_.replyMessage->setMessage(this->replyTarget_); - // Only enable reply label if inline replying - auto replyPrefix = "@" + this->replyTarget_->displayName; - auto plainText = this->ui_.textEdit->toPlainText().trimmed(); - - // This makes it so if plainText contains "@StreamerFan" and - // we are replying to "@Streamer" we don't just leave "Fan" - // in the text box - if (plainText.startsWith(replyPrefix)) - { - if (plainText.length() > replyPrefix.length()) + // add spacing between reply box and input box + this->ui_.vbox->setSpacing(this->marginForTheme()); + if (!this->isHidden()) { - if (plainText.at(replyPrefix.length()) == ',' || - plainText.at(replyPrefix.length()) == ' ') + // update maximum height to give space for message + this->setMaximumHeight(this->scaledMaxHeight()); + } + + // Only enable reply label if inline replying + auto replyPrefix = "@" + this->replyTarget_->displayName; + auto plainText = this->ui_.textEdit->toPlainText().trimmed(); + + // This makes it so if plainText contains "@StreamerFan" and + // we are replying to "@Streamer" we don't just leave "Fan" + // in the text box + if (plainText.startsWith(replyPrefix)) + { + if (plainText.length() > replyPrefix.length()) { - plainText.remove(0, replyPrefix.length() + 1); + if (plainText.at(replyPrefix.length()) == ',' || + plainText.at(replyPrefix.length()) == ' ') + { + plainText.remove(0, replyPrefix.length() + 1); + } + } + else + { + plainText.remove(0, replyPrefix.length()); } } - else + if (!plainText.isEmpty() && !plainText.startsWith(' ')) { - plainText.remove(0, replyPrefix.length()); + replyPrefix.append(' '); } + this->ui_.textEdit->setPlainText(replyPrefix + plainText + " "); + this->ui_.textEdit->moveCursor(QTextCursor::EndOfBlock); + this->ui_.textEdit->resetCompletion(); + this->ui_.replyLabel->setText("Replying to @" + + this->replyTarget_->displayName); } - if (!plainText.isEmpty() && !plainText.startsWith(' ')) + } + else + { + this->replyTarget_.reset(); + + if (this->enableInlineReplying_) { - replyPrefix.append(' '); + this->clearReplyTarget(); } - this->ui_.textEdit->setPlainText(replyPrefix + plainText + " "); - this->ui_.textEdit->moveCursor(QTextCursor::EndOfBlock); - this->ui_.textEdit->resetCompletion(); - this->ui_.replyLabel->setText("Replying to @" + - this->replyTarget_->displayName); } }