Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines: add a shortcut to check for classic #4709

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading