Skip to content

Commit 9cb91fb

Browse files
gedaretmsri
authored andcommitted
[clang-format] Fix regression in BAS_AlwaysBreak for-await (llvm#108634)
Fixes llvm#108589.
1 parent dd9698b commit 9cb91fb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
809809
if (Tok.Previous->isIf())
810810
return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
811811
return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
812-
tok::kw_switch);
812+
tok::kw_switch) &&
813+
!(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
813814
};
814815
auto IsFunctionCallParen = [](const FormatToken &Tok) {
815816
return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&

clang/unittests/Format/FormatTestJS.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,6 +2870,11 @@ TEST_F(FormatTestJS, BreakAfterOpenBracket) {
28702870
verifyFormat("failedUserIds.push(await subscriptioxxxxxxxxxxxxnSubset.map(\n"
28712871
" subscxxxxxxxxxxxxription => subscription.getUserId()));",
28722872
Style);
2873+
verifyFormat("for await (const packageId of ops.api.iterateEmbeddedFiles(\n"
2874+
" this.getFileId().getDriveFile(),\n"
2875+
" )) {\n"
2876+
"}",
2877+
Style);
28732878
}
28742879

28752880
} // namespace format

0 commit comments

Comments
 (0)