Skip to content

Commit

Permalink
Router: fix consistency based on src NL existence
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 27, 2024
1 parent e2e83c0 commit 75a5f8d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,17 @@ class Router(formatOps: FormatOps) {
nlSplit(nft)(1),
)
implicit val beforeMultiline = style.newlines.getBeforeMultiline
def getFolded(implicit fileLine: FileLine) = {
val isKeep = beforeMultiline.eq(Newlines.keep)
CtrlBodySplits.foldedNonEmptyNonComment(body, nlSplit(nft), isKeep)
}
if (
isCaseBodyABlock(nft, owner) ||
getClosingIfCaseBodyEnclosedAsBlock(nft, owner).isDefined
) Seq(baseSplit)
else if (nft.right.is[T.KwCase]) Seq(nlSplit(nft)(0))
else if (hasBreak() && !beforeMultiline.ignoreSourceSplit)
Seq(nlSplit(nft)(0))
getFolded.filter(_.isNL)
else if (bodyIsEmpty)
if (rt.isAny[T.RightBrace, T.Semicolon])
Seq(baseSplit, nlSplit(nft)(1))
Expand All @@ -553,10 +557,7 @@ class Router(formatOps: FormatOps) {
condIsDefined || beforeMultiline.eq(Newlines.classic) ||
getSingleStatExceptEndMarker(body).isEmpty
) withSlbSplit
else {
val isKeep = beforeMultiline.eq(Newlines.keep)
CtrlBodySplits.foldedNonEmptyNonComment(body, nlSplit(nft), isKeep)
}
else getFolded
}
// New statement
case FormatToken(_: T.Semicolon, _, StartsStatementRight(stmt))
Expand Down

0 comments on commit 75a5f8d

Please sign in to comment.