Skip to content

Commit

Permalink
Newlines: add a shortcut to check for classic
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Dec 31, 2024
1 parent 72ebee4 commit d3b1604
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ case class Newlines(
@inline
def keep: Boolean = source eq Newlines.keep
@inline
def classic: Boolean = source eq Newlines.classic
@inline
def keepBreak(hasBreak: => Boolean): Boolean = keep && hasBreak
@inline
def keepBreak(newlines: Int): Boolean = keepBreak(!FT.noBreak(newlines))
Expand Down Expand Up @@ -349,7 +351,7 @@ case class Newlines(
def isBeforeOpenParenDefnSite: Boolean = beforeOpenParenDefnSite.isDefined

private[scalafmt] lazy val encloseSelectChains = selectChains.enclose
.getOrElse(source.ne(Newlines.classic))
.getOrElse(!classic)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ object State {
new WithComparisons(compareCost, compareDepth, compareLineId)

def get(style: ScalafmtConfig): Ordering[State] =
if (style.newlines.source eq Newlines.classic) classicOrdering
else compactOrdering
if (style.newlines.classic) classicOrdering else compactOrdering

class WithComparisons(comparisons: (State, State) => Int*)
extends Ordering[State] {
Expand Down

0 comments on commit d3b1604

Please # to comment.