fix: Only display spaces between words in reply context (#4977)

This commit is contained in:
nerix
2023-11-26 11:15:35 +01:00
committed by GitHub
parent 1a685d7bd0
commit 854032fce9
6 changed files with 133 additions and 10 deletions
+13 -8
View File
@@ -664,16 +664,23 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
QString currentText;
container.first = FirstWord::Neutral;
bool firstIteration = true;
for (Word &word : this->words_)
{
if (firstIteration)
{
firstIteration = false;
}
else
{
currentText += ' ';
}
for (const auto &parsedWord : app->emotes->emojis.parse(word.text))
{
if (parsedWord.type() == typeid(QString))
{
if (!currentText.isEmpty())
{
currentText += ' ';
}
currentText += boost::get<QString>(parsedWord);
QString prev =
currentText; // only increments the ref-count
@@ -714,7 +721,8 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
container.addElementNoLineBreak(
(new ImageLayoutElement(*this, image, emoteSize))
->setLink(this->getLink()));
->setLink(this->getLink())
->setTrailingSpace(false));
}
}
}
@@ -723,9 +731,6 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
// Add the last of the pending message text to the container.
if (!currentText.isEmpty())
{
// Remove trailing space.
currentText = currentText.trimmed();
int width = metrics.horizontalAdvance(currentText);
container.addElementNoLineBreak(
getTextLayoutElement(currentText, width, false));