diff --git a/src/plugins/clangformat/clangformatbaseindenter.cpp b/src/plugins/clangformat/clangformatbaseindenter.cpp index 605ed2801c0..633435fb24f 100644 --- a/src/plugins/clangformat/clangformatbaseindenter.cpp +++ b/src/plugins/clangformat/clangformatbaseindenter.cpp @@ -7,9 +7,6 @@ #include -#include -#include - #include #include #include @@ -565,14 +562,6 @@ Utils::ChangeSet ClangFormatBaseIndenter::replacements(QByteArray buffer, Utils::EditOperations ClangFormatBaseIndenter::format(const TextEditor::RangesInLines &rangesInLines, FormattingMode mode) { - bool doFormatting = mode == FormattingMode::Forced || formatCodeInsteadOfIndent(); -#ifdef WITH_TESTS - doFormatting = doFormatting || CppEditor::CppToolsSettings::cppCodeStyle() - ->codeStyleSettings().forceFormatting; -#endif - if (!doFormatting) - return {}; - QTC_ASSERT(!m_fileName.isEmpty(), return {}); if (rangesInLines.empty()) return {}; diff --git a/src/plugins/clangformat/clangformatindenter.cpp b/src/plugins/clangformat/clangformatindenter.cpp index 00199827209..cf41925eeed 100644 --- a/src/plugins/clangformat/clangformatindenter.cpp +++ b/src/plugins/clangformat/clangformatindenter.cpp @@ -7,7 +7,9 @@ #include +#include #include +#include #include #include @@ -61,6 +63,10 @@ ClangFormatIndenter::ClangFormatIndenter(QTextDocument *doc) bool ClangFormatIndenter::formatCodeInsteadOfIndent() const { +#ifdef WITH_TESTS + if (CppEditor::CppToolsSettings::cppCodeStyle()->codeStyleSettings().forceFormatting) + return true; +#endif return getCurrentIndentationOrFormattingSettings(m_fileName) == ClangFormatSettings::Mode::Formatting; }