From 4b8635052f26360204ca589bc7536d77227a526d Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 25 Sep 2020 11:41:03 +0200 Subject: [PATCH] OutputFormatter: Run line parsers also for empty lines Empty lines can be relevant semantically, e.g. to mark the end of a block of messages. Amends 5cb74af166. Change-Id: I31cb32dcbf6a69f03324e0d2c00f95547c994d85 Reviewed-by: Christian Stenger --- src/libs/utils/outputformatter.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index d711569e7a8..6748d881748 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -288,12 +288,6 @@ void OutputFormatter::doAppendMessage(const QString &text, OutputFormat format) { QTextCharFormat charFmt = charFormat(format); - // This might cause insertion of a newline character. - if (text.isEmpty()) { - append(text, charFmt); - return; - } - QList formattedText = parseAnsi(text, charFmt); const QString cleanLine = std::accumulate(formattedText.begin(), formattedText.end(), QString(), [](const FormattedText &t1, const FormattedText &t2) { return t1.text + t2.text; }); @@ -315,8 +309,13 @@ void OutputFormatter::doAppendMessage(const QString &text, OutputFormat format) append(res.newContent.value(), charFmt); return; } - for (const FormattedText &output : linkifiedText(formattedText, res.linkSpecs)) + + const QList linkified = linkifiedText(formattedText, res.linkSpecs); + for (const FormattedText &output : linkified) append(output.text, output.format); + if (linkified.isEmpty()) + append({}, charFmt); // This might cause insertion of a newline character. + for (OutputLineParser * const p : qAsConst(involvedParsers)) { if (d->postPrintAction) d->postPrintAction(p);