Skip to content

Commit 1a822da

Browse files
committed
fix oopsies
1 parent c8a61b9 commit 1a822da

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/messages/MessageElement.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,27 @@ FontStyle TextElement::fontStyle() const noexcept
829829

830830
void TextElement::appendText(QStringView text)
831831
{
832-
for (auto word : text.split(' ')) // creates a QList
832+
for (auto word : text.tokenize(u' '))
833833
{
834834
this->words_.append(word.toString());
835835
}
836836
}
837837

838838
void TextElement::appendText(const QString &text)
839839
{
840-
this->appendText(QStringView{text});
840+
qsizetype firstSpace = text.indexOf(u' ');
841+
if (firstSpace == -1)
842+
{
843+
// reuse (ref) `text`
844+
this->words_.emplace_back(text);
845+
return;
846+
}
847+
848+
this->words_.emplace_back(text.sliced(0, firstSpace));
849+
for (auto word : QStringView{text}.sliced(firstSpace + 1).tokenize(u' '))
850+
{
851+
this->words_.emplace_back(word.toString());
852+
}
841853
}
842854

843855
QJsonObject TextElement::toJson() const

src/widgets/PluginRepl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ void stringify(sol::stack_proxy it, QString &s, size_t maxItems = 10,
334334
{
335335
s.append(u", ["_s);
336336
}
337-
s.append(QString::fromUtf8(
338-
key.data(), static_cast<qsizetype>(key.size())));
337+
s.append(QUtf8StringView(key));
339338
s.append("] = <dyn>");
340339
n++;
341340
}

0 commit comments

Comments
 (0)