From 3cfab3ace0450cd91784e10f4b44df964412afd2 Mon Sep 17 00:00:00 2001 From: howdy-partner <3364866+howdy-partner@users.noreply.github.com> Date: Thu, 10 Jun 2021 00:41:42 +0300 Subject: [PATCH] fix smiley bug --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index e330f49d3..491d2ca21 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1583,7 +1583,12 @@ void ChatWidget::addSmiley() smiley += QString(" "); // add preceding space when needed (not at start of text or preceding space already exists) 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(' ')) smiley = QString(" ") + smiley;