forked from qt-creator/qt-creator
ClangFormat: Use pre-existing code style settings
Instead using of default code style settings, this commit modifies the ClangFormat plugin to use the code style settings that were set before applying ClangFormat. By doing so, we preserve the previously defined code style. Fixes: QTCREATORBUG-29185 Change-Id: I347d44d5ed49a2c50e130a983b62c844c8964391 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -7,15 +7,16 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <cppeditor/cppcodestylepreferences.h>
|
||||
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <clang/Tooling/Core/Replacement.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -24,6 +25,8 @@
|
||||
#include <QDebug>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include <clang/Tooling/Core/Replacement.h>
|
||||
|
||||
namespace ClangFormat {
|
||||
|
||||
Internal::LlvmFileSystemAdapter llvmFileSystemAdapter = {};
|
||||
@@ -760,7 +763,7 @@ clang::format::FormatStyle overrideStyle(const Utils::FilePath &fileName)
|
||||
Utils::FilePath filePath = filePathToCurrentSettings(preferences);
|
||||
|
||||
if (!filePath.exists())
|
||||
return qtcStyle();
|
||||
return currentQtStyle(preferences);
|
||||
|
||||
clang::format::FormatStyle currentSettingsStyle;
|
||||
currentSettingsStyle.Language = clang::format::FormatStyle::LK_Cpp;
|
||||
@@ -769,7 +772,7 @@ clang::format::FormatStyle overrideStyle(const Utils::FilePath &fileName)
|
||||
.toStdString(),
|
||||
¤tSettingsStyle);
|
||||
QTC_ASSERT(error.value() == static_cast<int>(clang::format::ParseError::Success),
|
||||
return qtcStyle());
|
||||
return currentQtStyle(preferences));
|
||||
|
||||
return currentSettingsStyle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user