forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user