Skip to content

Commit

Permalink
Newlines: add more keepBreak overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed May 6, 2024
1 parent 279de7a commit bd2489d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -237,11 +237,13 @@ case class Newlines(
}

@inline
def keepBreak(newlines: => Int): Boolean = source.eq(Newlines.keep) &&
newlines != 0

def keepBreak(hasBreak: => Boolean): Boolean = source.eq(Newlines.keep) &&
hasBreak
@inline
def keepBreak(newlines: Int): Boolean =
keepBreak(!FormatToken.noBreak(newlines))
@inline
def keepBreak(ft: FormatToken): Boolean = keepBreak(ft.newlinesBetween)
def keepBreak(implicit ft: FormatToken): Boolean = keepBreak(ft.hasBreak)

val breakAfterInfix: AfterInfix = afterInfix.getOrElse {
source match {
Expand Down
Expand Up @@ -921,7 +921,7 @@ class Router(formatOps: FormatOps) {

val noSplitMod =
if (
style.newlines.keepBreak(tok) || {
style.newlines.keepBreak(newlines) || {
if (!handleImplicit) onlyConfigStyle
else style.newlines.forceBeforeImplicitParamListModifier
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ class Router(formatOps: FormatOps) {
)
}

val keepNoNL = style.newlines.source.eq(Newlines.keep) && tok.noBreak
val keepNoNL = style.newlines.keepBreak(tok.noBreak)
val preferNoSplit = keepNoNL && singleArgument
val oneArgOneLine = newlinePolicy &
(leftOwner match {
Expand Down

0 comments on commit bd2489d

Please sign in to comment.