summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Haas <lorenz.haas@histomatics.de>2017-02-28 19:10:01 +0100
committerLorenz Haas <lorenz.haas@histomatics.de>2017-03-01 08:53:44 +0000
commit2ce4bbc45888caca22df434239cee126977e4c1d (patch)
tree98a2dcca1401376333f9d250ec994b0c48c4def0
parent126a031ee2eae741095657f01c3ce3ac0129fecf (diff)
downloadqt-creator-2ce4bbc45888caca22df434239cee126977e4c1d.tar.gz
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 <david.schulz@qt.io>
-rw-r--r--src/plugins/beautifier/artisticstyle/artisticstyle.cpp7
-rw-r--r--src/plugins/beautifier/artisticstyle/artisticstylesettings.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
index 7cac510c11..3a34747838 100644
--- a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
+++ b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
@@ -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");
}
diff --git a/src/plugins/beautifier/artisticstyle/artisticstylesettings.h b/src/plugins/beautifier/artisticstyle/artisticstylesettings.h
index 6ae9d9a37b..3f5cd4cc17 100644
--- a/src/plugins/beautifier/artisticstyle/artisticstylesettings.h
+++ b/src/plugins/beautifier/artisticstyle/artisticstylesettings.h
@@ -40,7 +40,8 @@ class ArtisticStyleSettings : public AbstractSettings
public:
enum ArtisticStyleVersion {
- Version_2_03 = 203
+ Version_2_03 = 203,
+ Version_2_04 = 204
};
ArtisticStyleSettings();