Skip to content

Commit bd7da6e

Browse files
committed
[clang-format] Fix a regression on BAS_AlwaysBreak
Fixes llvm#107401.
1 parent 616a8ce commit bd7da6e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
861861
// or
862862
// caaaaaaaaaaaaaaaaaaaaal(
863863
// new SomethingElseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee());
864-
!IsSimpleFunction(Current)) {
864+
Current.isNot(tok::comment) && !IsSimpleFunction(Current)) {
865865
CurrentState.NoLineBreak = true;
866866
}
867867

clang/unittests/Format/FormatTestJS.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,5 +2850,13 @@ TEST_F(FormatTestJS, DontBreakFieldsAsGoToLabels) {
28502850
"};");
28512851
}
28522852

2853+
TEST_F(FormatTestJS, BreakAfterOpenBracket) {
2854+
auto Style = getGoogleStyle(FormatStyle::LK_JavaScript);
2855+
EXPECT_EQ(Style.AlignAfterOpenBracket, FormatStyle::BAS_AlwaysBreak);
2856+
verifyFormat("ctrl.onCopy(/** @type {!WizEvent}*/ (\n"
2857+
" {event, targetElement: {el: () => selectedElement}}));",
2858+
Style);
2859+
}
2860+
28532861
} // namespace format
28542862
} // end namespace clang

0 commit comments

Comments
 (0)