File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -2762,12 +2762,16 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
2762
2762
Current->SpacesRequiredBefore = 1 ;
2763
2763
}
2764
2764
2765
- Current->MustBreakBefore =
2766
- Current->MustBreakBefore || mustBreakBefore (Line, *Current);
2767
-
2768
- if (!Current->MustBreakBefore && InFunctionDecl &&
2769
- Current->is (TT_FunctionDeclarationName))
2770
- Current->MustBreakBefore = mustBreakForReturnType (Line);
2765
+ const auto &Children = Prev->Children ;
2766
+ if (!Children.empty () && Children.back ()->Last ->is (TT_LineComment)) {
2767
+ Current->MustBreakBefore = true ;
2768
+ } else {
2769
+ Current->MustBreakBefore =
2770
+ Current->MustBreakBefore || mustBreakBefore (Line, *Current);
2771
+ if (!Current->MustBreakBefore && InFunctionDecl &&
2772
+ Current->is (TT_FunctionDeclarationName))
2773
+ Current->MustBreakBefore = mustBreakForReturnType (Line);
2774
+ }
2771
2775
2772
2776
Current->CanBreakBefore =
2773
2777
Current->MustBreakBefore || canBreakBefore (Line, *Current);
Original file line number Diff line number Diff line change @@ -21934,6 +21934,30 @@ TEST_F(FormatTest, LambdaWithLineComments) {
21934
21934
"auto k = []() // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
21935
21935
"{ return; }",
21936
21936
LLVMWithBeforeLambdaBody);
21937
+
21938
+ LLVMWithBeforeLambdaBody.ColumnLimit = 0;
21939
+
21940
+ verifyFormat("foo([]()\n"
21941
+ " {\n"
21942
+ " bar(); //\n"
21943
+ " return 1; // comment\n"
21944
+ " }());",
21945
+ "foo([]() {\n"
21946
+ " bar(); //\n"
21947
+ " return 1; // comment\n"
21948
+ "}());",
21949
+ LLVMWithBeforeLambdaBody);
21950
+ verifyFormat("foo(\n"
21951
+ " 1, MACRO {\n"
21952
+ " baz();\n"
21953
+ " bar(); // comment\n"
21954
+ " },\n"
21955
+ " []() {});",
21956
+ "foo(\n"
21957
+ " 1, MACRO { baz(); bar(); // comment\n"
21958
+ " }, []() {}\n"
21959
+ ");",
21960
+ LLVMWithBeforeLambdaBody);
21937
21961
}
21938
21962
21939
21963
TEST_F(FormatTest, EmptyLinesInLambdas) {
You can’t perform that action at this time.
0 commit comments