diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-11-13 08:04:30 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-11-13 08:38:17 +0000 |
commit | f876a71fa1ddd9cd385c13f8ef55e153127c67e6 (patch) | |
tree | 844abd23913fa8522c8ad45738f3c76be100eed0 | |
parent | 36f4ed54df7af4b5a2dd03fa61a25392c8f745fa (diff) | |
download | qt-creator-f876a71fa1ddd9cd385c13f8ef55e153127c67e6.tar.gz |
ClangFormat: Improve current style detection
Check first if the current project already has .clang-format
configuration file.
Change-Id: Ic8cb5d37c32cd5b0c04485589caea95de933c264
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
-rw-r--r-- | src/plugins/clangformat/clangformatutils.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/clangformat/clangformatutils.cpp b/src/plugins/clangformat/clangformatutils.cpp index 9302e15361..39ebe5366d 100644 --- a/src/plugins/clangformat/clangformatutils.cpp +++ b/src/plugins/clangformat/clangformatutils.cpp @@ -172,10 +172,17 @@ clang::format::FormatStyle currentGlobalStyle() return currentStyle(true); } +static bool isCurrentStyleGlobal() +{ + Utils::FileName path = projectStylePath(); + if (path.appendPath(".clang-format").exists()) + return false; + return !CppCodeStyleSettings::currentProjectCodeStyle().has_value(); +} + clang::format::FormatStyle currentStyle() { - const bool isGlobal = !CppCodeStyleSettings::currentProjectCodeStyle().has_value(); - return currentStyle(isGlobal); + return currentStyle(isCurrentStyleGlobal()); } } |