Skip to content

Commit

Permalink
Router: keep then NL cost at 1 even if no space
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 3, 2024
1 parent bff727b commit c5ecf30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2008,12 +2008,12 @@ class Router(formatOps: FormatOps) {
Split(Newline, 1),
)
case FormatToken(_, _: T.KwThen | _: T.KwDo, _) =>
if (style.newlines.sourceIgnored || noBreak()) Seq(
Split(Space, 0)
val okSpace = style.newlines.sourceIgnored || noBreak()
Seq(
Split(!okSpace, 0)(Space)
.withOptimalToken(nextNonCommentSameLineAfter(ft).left),
Split(Newline, 1),
)
else Seq(Split(Newline, 0))
// Last else branch
case FormatToken(_: T.KwElse, _, _) if (leftOwner match {
case t: Term.If => t.elsep match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@ object a:
// c1
}
>>>
Idempotency violated
=> Diff (- obtained, + expected)
if reducePattern(caseBindingMap, scrutineeSym.termRef, cdef.pat)(using
- gadtCtx
- )
+ gadtCtx)
then {
object a:
if reducePattern(caseBindingMap, scrutineeSym.termRef, cdef.pat)(using
gadtCtx)
then {
// c1
}
<<< if(cond) indentation
trait A:
val cond =
Expand Down

0 comments on commit c5ecf30

Please sign in to comment.