aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/outputformatter.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-04 16:51:38 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-07 08:35:15 +0000
commitb0cad9e9c7aad209756fb2409520c0d048614dd9 (patch)
tree1cd9e91cfa0278ce35f3f3d272635d390d866e00 /src/libs/utils/outputformatter.cpp
parentf73f11d8c6418141581a77b97fc3c479a1bbaae5 (diff)
OutputFormatter: Fix visual glitchqds/v1.6.0-rc1qds/1.6.0-rc1
When inserting a line into an output window, we have to delay appending the line feed character. Otherwise strange visual effects appear under certain circumstances. I have no idea why. Fixes: QTCREATORBUG-24411 Change-Id: If8842ae4d9db36d514996b1f34dcca0432fafbfc Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/libs/utils/outputformatter.cpp')
-rw-r--r--src/libs/utils/outputformatter.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp
index 34c76d3ce6..49cb31d3e5 100644
--- a/src/libs/utils/outputformatter.cpp
+++ b/src/libs/utils/outputformatter.cpp
@@ -216,6 +216,7 @@ public:
PostPrintAction postPrintAction;
bool boldFontEnabled = true;
bool prependCarriageReturn = false;
+ bool prependLineFeed = false;
};
OutputFormatter::OutputFormatter() : d(new Private) { }
@@ -436,6 +437,7 @@ void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
startPos = crPos + 1;
}
+ flushTrailingNewline();
if (startPos < text.count())
d->cursor.insertText(text.mid(startPos), format);
}
@@ -495,6 +497,14 @@ void OutputFormatter::flushIncompleteLine()
d->incompleteLine.first.clear();
}
+void Utils::OutputFormatter::flushTrailingNewline()
+{
+ if (d->prependLineFeed) {
+ d->cursor.insertText("\n");
+ d->prependLineFeed = false;
+ }
+}
+
void OutputFormatter::dumpIncompleteLine(const QString &line, OutputFormat format)
{
if (line.isEmpty())
@@ -560,6 +570,7 @@ void OutputFormatter::flush()
{
if (!d->incompleteLine.first.isEmpty())
flushIncompleteLine();
+ flushTrailingNewline();
d->escapeCodeHandler.endFormatScope();
for (OutputLineParser * const p : qAsConst(d->lineParsers))
p->flush();
@@ -641,7 +652,8 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
dumpIncompleteLine(out.mid(startPos), format);
break;
}
- doAppendMessage(out.mid(startPos, eolPos - startPos + 1), format);
+ doAppendMessage(out.mid(startPos, eolPos - startPos), format);
+ d->prependLineFeed = true;
startPos = eolPos + 1;
}
}