Skip to content

Commit 014700f

Browse files
committed
Fix handling of Java/JS records and interfaces
1 parent 675426a commit 014700f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@ class LineJoiner {
512512
} else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace,
513513
TT_UnionLBrace)) {
514514
return tryMergeRecord(I, E, Limit);
515+
} else if (TheLine->Last->is(TT_RecordLBrace)) {
516+
// NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
517+
// and structs, but it seems that wrapping is still handled correctly
518+
// elsewhere.
519+
ShouldMerge = !Style.BraceWrapping.AfterClass ||
520+
(NextLine.First->is(tok::r_brace) &&
521+
!Style.BraceWrapping.SplitEmptyRecord);
515522
} else if (TheLine->InPPDirective ||
516523
TheLine->First->isNoneOf(tok::kw_class, tok::kw_enum,
517524
tok::kw_struct, Keywords.kw_record)) {

0 commit comments

Comments
 (0)