forked from qt-creator/qt-creator
Utils: Filter adjacent carriage returns in OutputFormatter
It shouldn't change the semantics, and it helps on some systems with strange line endings. Fixes: QTCREATORBUG-24556 Change-Id: I8158ddda458e5500bce6ce7b9ff4d5d981f88d7d Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
#include <memory>
|
||||
|
||||
@@ -803,7 +804,11 @@ QString SynchronousProcess::locateBinary(const QString &path, const QString &bin
|
||||
QString SynchronousProcess::normalizeNewlines(const QString &text)
|
||||
{
|
||||
QString res = text;
|
||||
res.replace(QLatin1String("\r\n"), QLatin1String("\n"));
|
||||
const auto newEnd = std::unique(res.begin(), res.end(), [](const QChar &c1, const QChar &c2) {
|
||||
return c1 == '\r' && c2 == '\r'; // QTCREATORBUG-24556
|
||||
});
|
||||
res.chop(std::distance(newEnd, res.end()));
|
||||
res.replace("\r\n", "\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -627,7 +627,7 @@ private:
|
||||
void Internal::CorePlugin::testOutputFormatter()
|
||||
{
|
||||
const QString input =
|
||||
"B to be handled by B\r\n"
|
||||
"B to be handled by B\r\r\n"
|
||||
"not to be handled\n\n\n\n"
|
||||
"A to be handled by A\n"
|
||||
"continuation for A\r\n"
|
||||
|
Reference in New Issue
Block a user