diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index a1a98a1fbec..87680cb0fde 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -108,8 +108,16 @@ QList OutputFormatter::parseAnsi(const QString &text, const QText void OutputFormatter::append(const QString &text, const QTextCharFormat &format) { - if (!text.isEmpty()) - d->cursor.insertText(text, format); + int startPos = 0; + int crPos = -1; + while ((crPos = text.indexOf('\r', startPos)) >= 0) { + d->cursor.insertText(text.mid(startPos, crPos - startPos), format); + d->cursor.clearSelection(); + d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); + startPos = crPos + 1; + } + if (startPos < text.count()) + d->cursor.insertText(text.mid(startPos), format); } QTextCursor &OutputFormatter::cursor() const diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index e6b03b2c7aa..bf939953d49 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -555,6 +555,7 @@ void Internal::CorePlugin::testOutputFormatter() "A next A\n" "A end of next A\n" " A trick\r\n" + "line with \r embedded carriage return\n" "B to be handled by B\n"; const QString output = "handled by B\n" @@ -566,6 +567,7 @@ void Internal::CorePlugin::testOutputFormatter() "handled by A\n" "handled by A\n" " A trick\n" + " embedded carriage return\n" "handled by B\n"; TestFormatterA formatterA; TestFormatterB formatterB;