forked from qt-creator/qt-creator
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:
@@ -152,14 +152,17 @@ CppEditor::CppCodeStyleSettings ClangFormatFile::toCppCodeStyleSettings(
|
|||||||
// to be false
|
// to be false
|
||||||
settings.indentAccessSpecifiers = (style.AccessModifierOffset != -1 * int(style.IndentWidth));
|
settings.indentAccessSpecifiers = (style.AccessModifierOffset != -1 * int(style.IndentWidth));
|
||||||
|
|
||||||
settings.indentNamespaceBody = style.NamespaceIndentation
|
if (style.NamespaceIndentation == FormatStyle::NamespaceIndentationKind::NI_All) {
|
||||||
== FormatStyle::NamespaceIndentationKind::NI_All;
|
settings.indentNamespaceBody = true;
|
||||||
settings.indentNamespaceBraces = settings.indentNamespaceBody;
|
settings.indentNamespaceBraces = settings.indentNamespaceBody;
|
||||||
|
}
|
||||||
|
|
||||||
settings.indentClassBraces = style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths;
|
if (style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths) {
|
||||||
|
settings.indentClassBraces = true;
|
||||||
settings.indentEnumBraces = settings.indentClassBraces;
|
settings.indentEnumBraces = settings.indentClassBraces;
|
||||||
settings.indentBlockBraces = settings.indentClassBraces;
|
settings.indentBlockBraces = settings.indentClassBraces;
|
||||||
settings.indentFunctionBraces = settings.indentClassBraces;
|
settings.indentFunctionBraces = settings.indentClassBraces;
|
||||||
|
}
|
||||||
|
|
||||||
settings.indentSwitchLabels = style.IndentCaseLabels;
|
settings.indentSwitchLabels = style.IndentCaseLabels;
|
||||||
#if LLVM_VERSION_MAJOR >= 11
|
#if LLVM_VERSION_MAJOR >= 11
|
||||||
|
|||||||
@@ -201,13 +201,13 @@ void fromCppCodeStyleSettings(clang::format::FormatStyle &style,
|
|||||||
else
|
else
|
||||||
style.AccessModifierOffset = -1 * style.IndentWidth;
|
style.AccessModifierOffset = -1 * style.IndentWidth;
|
||||||
|
|
||||||
if (settings.indentNamespaceBody || settings.indentNamespaceBraces)
|
if (settings.indentNamespaceBody && settings.indentNamespaceBraces)
|
||||||
style.NamespaceIndentation = FormatStyle::NamespaceIndentationKind::NI_All;
|
style.NamespaceIndentation = FormatStyle::NamespaceIndentationKind::NI_All;
|
||||||
else
|
else
|
||||||
style.NamespaceIndentation = FormatStyle::NamespaceIndentationKind::NI_None;
|
style.NamespaceIndentation = FormatStyle::NamespaceIndentationKind::NI_None;
|
||||||
|
|
||||||
if (settings.indentClassBraces || settings.indentEnumBraces || settings.indentBlockBraces
|
if (settings.indentClassBraces && settings.indentEnumBraces && settings.indentBlockBraces
|
||||||
|| settings.indentFunctionBraces)
|
&& settings.indentFunctionBraces)
|
||||||
style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
|
style.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
|
||||||
else
|
else
|
||||||
style.BreakBeforeBraces = FormatStyle::BS_Custom;
|
style.BreakBeforeBraces = FormatStyle::BS_Custom;
|
||||||
|
|||||||
Reference in New Issue
Block a user