[clang-format] Don't change breaking before CtorInitializerColon (#119522)
Don't change breaking before CtorInitializerColon with `ColumnLimit: 0`. Fixes #119519.
This commit is contained in:
@@ -461,9 +461,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
|
||||
getColumnLimit(State) ||
|
||||
CurrentState.BreakBeforeParameter) &&
|
||||
(!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
|
||||
(Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All ||
|
||||
Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
|
||||
Style.ColumnLimit != 0)) {
|
||||
(Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
|
||||
Style.ColumnLimit > 0 || Current.NewlinesBefore > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -492,7 +492,8 @@ private:
|
||||
ProbablyFunctionType && CurrentToken->Next &&
|
||||
(CurrentToken->Next->is(tok::l_paren) ||
|
||||
(CurrentToken->Next->is(tok::l_square) &&
|
||||
Line.MustBeDeclaration))) {
|
||||
(Line.MustBeDeclaration ||
|
||||
PrevNonComment->isTypeName(LangOpts))))) {
|
||||
OpeningParen.setType(OpeningParen.Next->is(tok::caret)
|
||||
? TT_ObjCBlockLParen
|
||||
: TT_FunctionTypeLParen);
|
||||
|
||||
@@ -14503,10 +14503,13 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
|
||||
FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
|
||||
DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
|
||||
FormatStyle::SFS_None;
|
||||
verifyFormat("A()\n"
|
||||
" : b(0) {\n"
|
||||
verifyFormat("A() : b(0) {\n"
|
||||
"}",
|
||||
"A():b(0){}", DoNotMergeNoColumnLimit);
|
||||
DoNotMergeNoColumnLimit);
|
||||
verifyNoChange("A()\n"
|
||||
" : b(0) {\n"
|
||||
"}",
|
||||
DoNotMergeNoColumnLimit);
|
||||
verifyFormat("A()\n"
|
||||
" : b(0) {\n"
|
||||
"}",
|
||||
|
||||
Reference in New Issue
Block a user