forked from qt-creator/qt-creator
OutputFormatter: Fix behavior of text with different format after \r
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 79cfb784be.
Fixes: QTCREATORBUG-22179
Change-Id: I4208008095f3e186aa9b4cee99fa5cd807ffdbcb
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
346b5aa4ad
commit
f1665c02aa
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user