From 7c28e7964455c50bec3d4fc9d3fe2c709761b9a6 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Mon, 19 Jun 2023 17:51:55 -0400 Subject: [PATCH] Fix regenerate response with references. --- gpt4all-chat/responsetext.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gpt4all-chat/responsetext.cpp b/gpt4all-chat/responsetext.cpp index 3aba1bd9..1b8b9592 100644 --- a/gpt4all-chat/responsetext.cpp +++ b/gpt4all-chat/responsetext.cpp @@ -367,9 +367,14 @@ void ResponseText::handleTextChanged() return; m_isProcessingText = true; - QTextDocument* doc = m_textDocument->textDocument(); handleContextLinks(); handleCodeBlocks(); + // We insert an invisible char at the end to make sure the document goes back to the default + // text format + QTextDocument* doc = m_textDocument->textDocument(); + QTextCursor cursor(doc); + QString invisibleCharacter = QString(QChar(0xFEFF)); + cursor.insertText(invisibleCharacter, QTextCharFormat()); m_isProcessingText = false; }