Clang格式并不总是尊重BinPackParameters:false

问题描述 投票:1回答:1

我正在尝试使用Visual Studio 2017的.clang格式文件,但它似乎并不总是尊重我设置为false的BinPackParameters参数。

设置以下参数:

AlignAfterOpenBracket: AlwaysBreak
AllowAllParametersOfDeclarationOnNextLine: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 110

我希望我的方法调用太长(即大于ColumnWidth参数)总是将每个参数换行到一个方法,这样它们每个都在不同的行上,如下所示:

LongMethodNameCall(
    someLongParameter1,
    someLongParameter2,
    someLongParameter3,
    someLongParameter4 );

有时是这种情况,但有时我得到:

LongMethodNameCall(
    someLongParameter1, someLongParameter2, someLongParameter3, someLongParameter4 );

要清楚,我希望它在开始括号后总是换行,并且如果整个语句超过ColumnWidth参数,则将每个参数放在一行上。

这是我的.clang格式文件:

Language: Cpp
#DisableFormat: true

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
    AfterClass:      true   
    AfterControlStatement: true
    AfterEnum:       true
    AfterFunction:   true          
    AfterNamespace:  false                
    AfterStruct:     true
    AfterUnion:      true
    BeforeCatch:     true
    BeforeElse:      true   
    IndentBraces:    false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: true
ColumnLimit: 110
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeCategories:
    - Regex:           '\/stdafx.h'
      Priority:        -1
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 100
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 0
PenaltyBreakFirstLessLess: 100
PenaltyBreakString: 50
PenaltyExcessCharacter: 20
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: true
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: true
SpacesInSquareBrackets: true
TabWidth: 4
UseTab: Never
c++ clang-format
1个回答
0
投票

BinPackParameters:false未被遵守的唯一时间是AllowAllParametersOfDeclarationOnNextLine设置为true,这不是您的情况。

我尝试使用提供的配置,无法重现该问题。

该工具可能同时进行了修改。

© www.soinside.com 2019 - 2024. All rights reserved.