diff --git a/gui/chatblockmodel.cpp b/gui/chatblockmodel.cpp index 9b70b55..f93c1a9 100644 --- a/gui/chatblockmodel.cpp +++ b/gui/chatblockmodel.cpp @@ -194,26 +194,28 @@ QString ChatBlockModel::highlightCode(const QString &code, const QString &langua QString ChatBlockModel::renderMarkdown(const QString &markdown) const { // Pre-process: render blocks as styled boxes. - // Manual global-match loop instead of replace-with-lambda, which requires - // Qt 6.5+ and isn't available on all target systems. + // These appear as prose between code fences (the server closes the tool + // output fence before the interruption and reopens it after). static const QRegularExpression interruptionRe( R"(\n([\s\S]*?)\n)"); - QString processed; + QString processed = markdown; { int cursor = 0; + QString rebuilt; auto it = interruptionRe.globalMatch(markdown); while (it.hasNext()) { const auto match = it.next(); - processed += markdown.mid(cursor, match.capturedStart() - cursor); + rebuilt += markdown.mid(cursor, match.capturedStart() - cursor); const QString content = match.captured(1).toHtmlEscaped(); - processed += QStringLiteral( + rebuilt += QStringLiteral( "
" "\u26A0\uFE0F User interruption\n") + content + QStringLiteral("
"); cursor = match.capturedEnd(); } - processed += markdown.mid(cursor); + rebuilt += markdown.mid(cursor); + processed = rebuilt; } static const QRegularExpression fenceRe(