ClangFormat: Make the behavior of the braces tab clearer

Fixes: QTCREATORBUG-29069
Change-Id: I078b7fbb6f98088f615d74a189cce00f8e5fa5fe
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-06-27 10:10:22 +02:00
parent 65b1088a17
commit 0720042e1c
2 changed files with 13 additions and 10 deletions

View File

@@ -152,14 +152,17 @@ CppEditor::CppCodeStyleSettings ClangFormatFile::toCppCodeStyleSettings(
// to be false
settings.indentAccessSpecifiers = (style.AccessModifierOffset != -1 * int(style.IndentWidth));
settings.indentNamespaceBody = style.NamespaceIndentation
== FormatStyle::NamespaceIndentationKind::NI_All;
settings.indentNamespaceBraces = settings.indentNamespaceBody;
if (style.NamespaceIndentation == FormatStyle::NamespaceIndentationKind::NI_All) {
settings.indentNamespaceBody = true;
settings.indentNamespaceBraces = settings.indentNamespaceBody;
}
settings.indentClassBraces = style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths;
settings.indentEnumBraces = settings.indentClassBraces;
settings.indentBlockBraces = settings.indentClassBraces;
settings.indentFunctionBraces = settings.indentClassBraces;
if (style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths) {
settings.indentClassBraces = true;
settings.indentEnumBraces = settings.indentClassBraces;
settings.indentBlockBraces = settings.indentClassBraces;
settings.indentFunctionBraces = settings.indentClassBraces;
}
settings.indentSwitchLabels = style.IndentCaseLabels;
#if LLVM_VERSION_MAJOR >= 11