Skip to content

Commit

Permalink
FormatOps: can't look at breaks for fold/unfold
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Apr 1, 2024
1 parent 91e203b commit d145a9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class FormatOps(
case _: T.RightParen if start.left.is[T.LeftParen] => None
case c: T.Comment if start.noBreak && tokens.isBreakAfterRight(start) =>
Some(c)
case _ if start.noBreak && isInfix => None
case _ if !style.newlines.formatInfix && start.noBreak && isInfix => None
case _ => Some(start.left)
}

Expand Down
12 changes: 4 additions & 8 deletions scalafmt-tests/src/test/resources/newlines/source_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,8 @@ object a {
}
>>>
object a {
the[Exception] thrownBy {
SizeUtils.calculate(segments, "user")
} should have message
"""Cannot resolve column name "user" among (segment_id);"""
the[Exception] thrownBy { SizeUtils.calculate(segments, "user") } should
have message """Cannot resolve column name "user" among (segment_id);"""
}
<<< 1.c.1: block followed by an infix, overflowing if no break
maxColumn = 80
Expand All @@ -163,10 +161,8 @@ object a {
}
>>>
object a {
the[Exception] thrownBy {
SizeUtils.calculate(segments, "user")
} should have message
"""Cannot resolve column name "user" among (segment_id);"""
the[Exception] thrownBy { SizeUtils.calculate(segments, "user") } should
have message """Cannot resolve column name "user" among (segment_id);"""
}
<<< 1.c.2: block followed by an infix, overflowing if no break
maxColumn = 80
Expand Down
16 changes: 8 additions & 8 deletions scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -1706,11 +1706,11 @@ object a {
} tag (ScalafmtTagPack: _*)
}
>>>
Idempotency violated
=> Diff (- obtained, + expected)
session: FormatSession
- ) = Def.task(session.checkTrackedSources(sources, dirs)) tag
- (ScalafmtTagPack: _*)
+ ) =
+ Def.task(session.checkTrackedSources(sources, dirs)) tag (ScalafmtTagPack: _*)
}
object a {
private def scalafmtCheckTask(
sources: Seq[File],
dirs: Seq[File],
session: FormatSession
) = Def.task(session.checkTrackedSources(sources, dirs)) tag
(ScalafmtTagPack: _*)
}

0 comments on commit d145a9c

Please sign in to comment.