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();
QString textToInsert(link.value + " ");
auto symbolBeforeCursor =
getInputText()[cursor.position() - 1];
// If symbol before cursor isn't space or empty
// Then insert space before emote.
if (!symbolBeforeCursor.isSpace() &&
!symbolBeforeCursor.isNull()) {
if (cursor.position() > 0 &&
!this->getInputText()[cursor.position() - 1].isSpace()) {
textToInsert = " " + textToInsert;
}
this->insertText(textToInsert);