From f1665c02aa3dece978278e3a64b60740f378d6b3 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 23 Mar 2019 23:02:01 +0200 Subject: OutputFormatter: Fix behavior of text with different format after \r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example, git rebase for outdated Git versions has: stdout: Rebasing (1/2)\r stdout: Rebasing (2/2)\r stderr: Successfully rebased and updated refs/heads/master.\n The stderr is supposed to overwrite the Rebasing line. Without redirections, this is what you get on the terminal. Conform to that by deleting a line that ends with \r even if the next output has different format. The only exception is when the following *starts with* \n. On this case, it will behave as \r\n, meaning it will *not* overwrite the previous line, and will continue on the next line. This amends commit 79cfb784be49633fbdafd5fe5b4a3011c5c064ae. Fixes: QTCREATORBUG-22179 Change-Id: I4208008095f3e186aa9b4cee99fa5cd807ffdbcb Reviewed-by: André Hartmann Reviewed-by: Christian Kandeler --- src/libs/utils/outputformatter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/libs/utils/outputformatter.cpp') diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index d978e757c7..ec85a748a6 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -41,7 +41,6 @@ public: QTextCharFormat formats[NumberOfFormats]; QTextCursor cursor; AnsiEscapeCodeHandler escapeCodeHandler; - OutputFormat lastFormat = NumberOfFormats; bool boldFontEnabled = true; }; @@ -72,9 +71,8 @@ void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText) void OutputFormatter::appendMessage(const QString &text, OutputFormat format) { - if (!d->cursor.atEnd() && format != d->lastFormat) + if (!d->cursor.atEnd() && text.startsWith('\n')) d->cursor.movePosition(QTextCursor::End); - d->lastFormat = format; appendMessage(text, d->formats[format]); } -- cgit v1.2.3