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>
This commit is contained in:
Ivan Donchevskii
2018-11-13 08:04:30 +01:00
parent 36f4ed54df
commit f876a71fa1

View File

@@ -172,10 +172,17 @@ clang::format::FormatStyle currentGlobalStyle()
return currentStyle(true); 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() clang::format::FormatStyle currentStyle()
{ {
const bool isGlobal = !CppCodeStyleSettings::currentProjectCodeStyle().has_value(); return currentStyle(isCurrentStyleGlobal());
return currentStyle(isGlobal);
} }
} }