mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Improved insertion of emotes from popup.
This commit is contained in:
parent
88477829ef
commit
f813c2de3b
1 changed files with 12 additions and 1 deletions
|
@ -152,7 +152,18 @@ void SplitInput::openEmotePopup()
|
|||
this->emotePopup_ = std::make_unique<EmotePopup>();
|
||||
this->emotePopup_->linkClicked.connect([this](const Link &link) {
|
||||
if (link.type == Link::InsertText) {
|
||||
this->insertText(link.value + " ");
|
||||
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()) {
|
||||
textToInsert = " " + textToInsert;
|
||||
}
|
||||
this->insertText(textToInsert);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue