Commit 2ce4bbc4 authored by Lorenz Haas's avatar Lorenz Haas

Beautifier: Fix formatting with AStyle and make it more robust

Only version 2.04 added an extra newline. Later versions are fixed, so
the should not remove a newline.
In addition if piping is enabled we stream "\n" line endings so tell
AStyle this explicitly by passing -z2. This disables the automatic
detection which can be faulty with short code fragments.

Task-number: QTCREATORBUG-17546
Change-Id: Ib90526234bfbc4d3530fd9c3a15bdfb3af02bebd
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 126a031e
......@@ -160,10 +160,13 @@ Command ArtisticStyle::command(const QString &cfgFile) const
command.addOption("-q");
command.addOption("--options=" + cfgFile);
if (m_settings->version() > ArtisticStyleSettings::Version_2_03) {
const int version = m_settings->version();
if (version > ArtisticStyleSettings::Version_2_03) {
command.setProcessing(Command::PipeProcessing);
command.setPipeAddsNewline(true);
if (version == ArtisticStyleSettings::Version_2_04)
command.setPipeAddsNewline(true);
command.setReturnsCRLF(Utils::HostOsInfo::isWindowsHost());
command.addOption("-z2");
} else {
command.addOption("%file");
}
......
......@@ -40,7 +40,8 @@ class ArtisticStyleSettings : public AbstractSettings
public:
enum ArtisticStyleVersion {
Version_2_03 = 203
Version_2_03 = 203,
Version_2_04 = 204
};
ArtisticStyleSettings();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment