forked from qt-creator/qt-creator
Beautifier: Handle CRLF for Artistic Style on Windows correctly
Artistic Style will return CRLF on Windows if you are using a pipe. Thus we have to convert it. Change-Id: Id24cac2f35cc3c1978d709fb6c66cee8c8814e34 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -198,9 +198,14 @@ QString BeautifierPlugin::format(const QString &text, const Command &command,
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (command.pipeAddsNewline()) {
|
||||
const bool addsNewline = command.pipeAddsNewline();
|
||||
const bool returnsCRLF = command.returnsCRLF();
|
||||
if (addsNewline || returnsCRLF) {
|
||||
QString formatted = QString::fromUtf8(process.readAllStandardOutput());
|
||||
formatted.remove(QRegExp(QLatin1String("(\\r\\n|\\n)$")));
|
||||
if (addsNewline)
|
||||
formatted.remove(QRegExp(QLatin1String("(\\r\\n|\\n)$")));
|
||||
if (returnsCRLF)
|
||||
formatted.replace(QLatin1String("\r\n"), QLatin1String("\n"));
|
||||
return formatted;
|
||||
}
|
||||
return QString::fromUtf8(process.readAllStandardOutput());
|
||||
|
||||
Reference in New Issue
Block a user