From 29816730e432da02a4773a29bcc17c4c92920f20 Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 30 May 2022 19:17:47 +0000 Subject: [PATCH] Add space after an autocomplete Adds a space automatically after an autocomplete if the last char isn't one. Implements network/neochat#132 --- src/chatdocumenthandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/chatdocumenthandler.cpp b/src/chatdocumenthandler.cpp index c9a64533a..c33cd9a8a 100644 --- a/src/chatdocumenthandler.cpp +++ b/src/chatdocumenthandler.cpp @@ -204,6 +204,12 @@ void ChatDocumentHandler::replaceAutoComplete(const QString &word) } cursor.insertHtml(word); + + // Add space after autocomplete if not already there + if (!cursor.block().text().endsWith(QStringLiteral(" "))) { + cursor.insertText(QStringLiteral(" ")); + } + m_lastState = cursor.block().text(); cursor.endEditBlock(); }