Skip to content

Commit

Permalink
Router: always add space between ( and comment
Browse files Browse the repository at this point in the history
That is done in some places and missed in others; and there's always a
space between a comment and a `)`.
  • Loading branch information
kitbellew committed Oct 31, 2022
1 parent f7ab935 commit e71daa6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ class Router(formatOps: FormatOps) {
Num(if (willBreak) style.indent.main else 0)
}
}
val useSpace = style.spaces.inParentheses
val useSpace = style.spaces.inParentheses || right.is[T.Comment]
Split(Space(useSpace), 0).withIndent(indent, close, Before)
}
def spaceSplit(implicit fileLine: FileLine) =
Expand Down
4 changes: 2 additions & 2 deletions scalafmt-tests/src/test/resources/default/For.stat
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ for ((l, r) ← /* c1 */ ( /* c2 */ Seq(
) checkOne(looker, l, r)
>>>
for (
(l, r) ← /* c1 */ (/* c2 */ Seq(
(l, r) ← /* c1 */ ( /* c2 */ Seq(
SelectString("a/b/c") -> None,
SelectString("akka://all-systems/Nobody") -> None,
SelectPath(system / "hallo") -> None,
Expand Down Expand Up @@ -140,7 +140,7 @@ for ((l, r) ← /* c1 */ ( /* c2 */Seq(
) checkOne(looker, l, r)
>>>
for (
(l, r) ← /* c1 */ (/* c2 */ Seq(
(l, r) ← /* c1 */ ( /* c2 */ Seq(
SelectString("a/b/c") -> None,
SelectString("akka://all-systems/Nobody") -> None,
SelectPath(system / "hallo") -> None,
Expand Down
6 changes: 3 additions & 3 deletions scalafmt-tests/src/test/resources/rewrite/AvoidInfix3.stat
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ object a {
/* c2 */
)
b.c( /* c1 */
/* c2 */ (/* c3 */ )
/* c2 */ ( /* c3 */ )
)
b.c( /* c1 */
/* c2 */ d,
Expand All @@ -194,7 +194,7 @@ object a {
/* c2 */ ( /* c3 */ d, e)
)
b.c( /* c1 */
(/* c2 */ c + d /* c3 */ ).foo
( /* c2 */ c + d /* c3 */ ).foo
)
}
<<< args with parens, targs and comments
Expand Down Expand Up @@ -228,7 +228,7 @@ object a {
>>>
object a {
b.c[A]( /* c1 */
/* c2 */ (/* c3 */ )
/* c2 */ ( /* c3 */ )
)
}
<<< args with tuple, targs and comments
Expand Down
18 changes: 9 additions & 9 deletions scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat
Original file line number Diff line number Diff line change
Expand Up @@ -807,19 +807,19 @@ object a {
>>>
object a {
b c /* c1 */
(/* c2 */ )
( /* c2 */ )
b c /* c1 */
(/* c2 */ (/* c3 */ ))
( /* c2 */ ( /* c3 */ ))
b c /* c1 */
(/* c2 */ (/* c3 */ /* c4 */ ))
( /* c2 */ ( /* c3 */ /* c4 */ ))
b c /* c1 */
(/* c2 */ d, e)
( /* c2 */ d, e)
b c /* c1 */
(/* c2 */ ( /* c3 */ d, e))
( /* c2 */ ( /* c3 */ d, e))
b c /* c1 */
(/* c2 */ ( /* c3 */ /* c4 */ d, e))
( /* c2 */ ( /* c3 */ /* c4 */ d, e))
b c /* c1 */
(/* c2 */ c + d /* c3 */ ).foo
( /* c2 */ c + d /* c3 */ ).foo
}
<<< infix with parens, targs and comments
object a {
Expand All @@ -834,10 +834,10 @@ object a {
object a {
b c /* c1 */
[A] /* c2 */
(/* c3 */ )
( /* c3 */ )
b c /* c1 */
[A] /* c2 */
(/* c3 */ d, e)
( /* c3 */ d, e)
}
<<< if with/without then
runner.dialect = scala3
Expand Down

0 comments on commit e71daa6

Please sign in to comment.