Skip to content

Commit

Permalink
Router: don't fold after single-line comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 7, 2024
1 parent 3ad47eb commit 471be92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,9 @@ class Router(formatOps: FormatOps) {
val spacePolicy = SingleLineBlock(lambdaToken) ==> {
def before = Policy.End < close ==> Policy.on(close, "NODANGLE") {
case Decision(FormatToken(bc, `close`, _), _) =>
val isSpace = bc.is[T.Comment] || style.spaces.inParentheses
Seq(Split(Space(isSpace), 0))
if (bc.is[T.Comment])
if (bc.text.startsWith("//")) Nil else Seq(Split(Space, 0))
else Seq(Split(Space(style.spaces.inParentheses), 0))
}
Policy ? lambdaIsABlock ||
Policy.RelayOnSplit.by(Policy.End == lambdaLeft.getOrElse(close))(
Expand Down
10 changes: 3 additions & 7 deletions scalafmt-tests/shared/src/test/resources/rewrite/AvoidInfix.stat
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,6 @@ newlines.avoidForSimpleOverflow = all
def templates = symbols.filter (x => x.isClass || x.isTrait || x == AnyRefClass// which is now a type alias */
).toSet
>>>
test does not parse: [dialect scala213] `)` expected but `end of file` found
def templates = symbols.filter(x => x.isClass || x.isTrait || x == AnyRefClass // which is now a type alias */ )
.toSet
^
====== full result: ======
def templates = symbols.filter(x => x.isClass || x.isTrait || x == AnyRefClass // which is now a type alias */ )
.toSet
def templates = symbols.filter(x =>
x.isClass || x.isTrait || x == AnyRefClass // which is now a type alias */
).toSet
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1502307, "total explored")
assertEquals(explored, 1502510, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down

0 comments on commit 471be92

Please sign in to comment.