make emote popup emote insertions less risky

This commit is contained in:
Rasmus Karlsson 2018-09-21 22:01:21 +02:00
parent 92bf1adf88
commit a733b6975d

View file

@ -155,12 +155,10 @@ void SplitInput::openEmotePopup()
QTextCursor cursor = this->ui_.textEdit->textCursor(); QTextCursor cursor = this->ui_.textEdit->textCursor();
QString textToInsert(link.value + " "); QString textToInsert(link.value + " ");
auto symbolBeforeCursor =
getInputText()[cursor.position() - 1];
// If symbol before cursor isn't space or empty // If symbol before cursor isn't space or empty
// Then insert space before emote. // Then insert space before emote.
if (!symbolBeforeCursor.isSpace() && if (cursor.position() > 0 &&
!symbolBeforeCursor.isNull()) { !this->getInputText()[cursor.position() - 1].isSpace()) {
textToInsert = " " + textToInsert; textToInsert = " " + textToInsert;
} }
this->insertText(textToInsert); this->insertText(textToInsert);