Merge pull request #2429 from howdy-partner/smiley-fix

fix smiley bug
This commit is contained in:
csoler 2021-06-24 20:35:55 +02:00 committed by GitHub
commit 9a6257e3c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1583,7 +1583,12 @@ void ChatWidget::addSmiley()
smiley += QString(" "); smiley += QString(" ");
// add preceding space when needed (not at start of text or preceding space already exists) // add preceding space when needed (not at start of text or preceding space already exists)
QString plainText = ui->chatTextEdit->toPlainText(); QString plainText = ui->chatTextEdit->toPlainText();
QChar start = plainText[ui->chatTextEdit->textCursor().position() - 1];
int startPosition = ui->chatTextEdit->textCursor().position();
if (startPosition > 0)
startPosition -= 1;
QChar start = plainText[startPosition];
if(!ui->chatTextEdit->textCursor().atStart() && start != QChar(' ')) if(!ui->chatTextEdit->textCursor().atStart() && start != QChar(' '))
smiley = QString(" ") + smiley; smiley = QString(" ") + smiley;