[clang] [clang-format] Fix a regression on BAS_AlwaysBreak (PR #107506)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 19:46:48 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Owen Pan (owenca)
<details>
<summary>Changes</summary>
Fixes #<!-- -->107401.
---
Full diff: https://github.com/llvm/llvm-project/pull/107506.diff
2 Files Affected:
- (modified) clang/lib/Format/ContinuationIndenter.cpp (+1-1)
- (modified) clang/unittests/Format/FormatTestJS.cpp (+8)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/107506
More information about the cfe-commits
mailing list