Skip to content

Commit 89899b7

Browse files
committed
Do not print spaces on double breaks
1 parent d5d991d commit 89899b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
3838
def result(): String = sb.result()
3939

4040
def lineBreak(): String = "\n" + (" " * indent)
41+
def doubleLineBreak(): String = "\n\n" + (" " * indent)
4142

4243
def printTree(tree: Tree): Buffer = tree match {
4344
case tree @ PackageClause(Term.Ident(name), stats) =>
@@ -391,14 +392,13 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
391392

392393
def printStats(stats: List[Tree], expr: Tree): Unit = {
393394
def printSeparator(nextStats: List[Tree]) = {
394-
this += lineBreak()
395395
// Avoid accidental application of opening `{` on next line with a double break
396396
val next = if (nextStats.isEmpty) expr else nextStats.head
397397
next match {
398-
case Term.Block(DefDef("while$" | "doWhile$", _, _, _, _) :: Nil, _) =>
399-
case Term.Block(_, _) => this += lineBreak()
400-
case Term.Inlined(_, _, _) => this += lineBreak()
401-
case _ =>
398+
case Term.Block(DefDef("while$" | "doWhile$", _, _, _, _) :: Nil, _) => this += lineBreak()
399+
case Term.Block(_, _) => this += doubleLineBreak()
400+
case Term.Inlined(_, _, _) => this += doubleLineBreak()
401+
case _ => this += lineBreak()
402402
}
403403
}
404404
def printSeparated(list: List[Tree]): Unit = list match {

0 commit comments

Comments
 (0)