https://github.com/owenca created https://github.com/llvm/llvm-project/pull/107506
Fixes #107401. >From bd7da6ec9afabd829010db4c33d088590ab68b5a Mon Sep 17 00:00:00 2001 From: Owen Pan <owenpi...@gmail.com> Date: Thu, 5 Sep 2024 19:44:46 -0700 Subject: [PATCH] [clang-format] Fix a regression on BAS_AlwaysBreak Fixes #107401. --- clang/lib/Format/ContinuationIndenter.cpp | 2 +- clang/unittests/Format/FormatTestJS.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 5843571718b3a2..f65c1640a8765a 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -861,7 +861,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // or // caaaaaaaaaaaaaaaaaaaaal( // new SomethingElseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee()); - !IsSimpleFunction(Current)) { + Current.isNot(tok::comment) && !IsSimpleFunction(Current)) { CurrentState.NoLineBreak = true; } diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 4b29ba720f6823..a0b663170c7b33 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -2850,5 +2850,13 @@ TEST_F(FormatTestJS, DontBreakFieldsAsGoToLabels) { "};"); } +TEST_F(FormatTestJS, BreakAfterOpenBracket) { + auto Style = getGoogleStyle(FormatStyle::LK_JavaScript); + EXPECT_EQ(Style.AlignAfterOpenBracket, FormatStyle::BAS_AlwaysBreak); + verifyFormat("ctrl.onCopy(/** @type {!WizEvent}*/ (\n" + " {event, targetElement: {el: () => selectedElement}}));", + Style); +} + } // namespace format } // end namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits