[clang-format] Make EndsInComma in ContinuationIndenter consistent (#146256)
This commit is contained in:
@@ -1929,6 +1929,15 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
|
||||
return;
|
||||
}
|
||||
|
||||
const bool EndsInComma = [](const FormatToken *Tok) {
|
||||
if (!Tok)
|
||||
return false;
|
||||
const auto *Prev = Tok->getPreviousNonComment();
|
||||
if (!Prev)
|
||||
return false;
|
||||
return Prev->is(tok::comma);
|
||||
}(Current.MatchingParen);
|
||||
|
||||
unsigned NewIndent;
|
||||
unsigned LastSpace = CurrentState.LastSpace;
|
||||
bool AvoidBinPacking;
|
||||
@@ -1948,9 +1957,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
|
||||
NewIndent = CurrentState.LastSpace + Style.ContinuationIndentWidth;
|
||||
}
|
||||
const FormatToken *NextNonComment = Current.getNextNonComment();
|
||||
bool EndsInComma = Current.MatchingParen &&
|
||||
Current.MatchingParen->Previous &&
|
||||
Current.MatchingParen->Previous->is(tok::comma);
|
||||
AvoidBinPacking = EndsInComma || Current.is(TT_DictLiteral) ||
|
||||
Style.isProto() || !Style.BinPackArguments ||
|
||||
(NextNonComment && NextNonComment->isOneOf(
|
||||
@@ -1984,11 +1990,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
|
||||
LastSpace = std::max(LastSpace, CurrentState.Indent);
|
||||
}
|
||||
|
||||
bool EndsInComma =
|
||||
Current.MatchingParen &&
|
||||
Current.MatchingParen->getPreviousNonComment() &&
|
||||
Current.MatchingParen->getPreviousNonComment()->is(tok::comma);
|
||||
|
||||
// If ObjCBinPackProtocolList is unspecified, fall back to BinPackParameters
|
||||
// for backwards compatibility.
|
||||
bool ObjCBinPackProtocolList =
|
||||
|
||||
@@ -27953,13 +27953,6 @@ TEST_F(FormatTest, AlignArrayOfStructuresLeftAlignmentNonSquare) {
|
||||
"};",
|
||||
Style);
|
||||
verifyFormat("void foo() {\n"
|
||||
" auto thing = test{\n"
|
||||
" {\n"
|
||||
" {13}, {something}, // A\n"
|
||||
" }\n"
|
||||
" };\n"
|
||||
"}",
|
||||
"void foo() {\n"
|
||||
" auto thing = test{\n"
|
||||
" {\n"
|
||||
" {13},\n"
|
||||
@@ -28017,13 +28010,6 @@ TEST_F(FormatTest, AlignArrayOfStructuresRightAlignmentNonSquare) {
|
||||
"};",
|
||||
Style);
|
||||
verifyFormat("void foo() {\n"
|
||||
" auto thing = test{\n"
|
||||
" {\n"
|
||||
" {13}, {something}, // A\n"
|
||||
" }\n"
|
||||
" };\n"
|
||||
"}",
|
||||
"void foo() {\n"
|
||||
" auto thing = test{\n"
|
||||
" {\n"
|
||||
" {13},\n"
|
||||
|
||||
Reference in New Issue
Block a user