scalameta / scalafmt

Code formatter for Scala
http://scalameta.org/scalafmt
Apache License 2.0
1.42k stars 276 forks source link

Idempotence issue when trailingCommas is "always" and omitting braces #4058

Closed finalchild closed 2 months ago

finalchild commented 2 months ago

Configuration (required)

version = 3.8.2
runner.dialect = scala3
preset = default
rewrite.trailingCommas.style = "always"

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt filename.scala

Steps

Given code like this:

f(
  if true then 0
  else
    ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
  ,
)

repeat running scalafmt

Problem

Scalafmt formats code like this:

f(
  if true then 0
  else
    ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg,
)

and run it again, rolls back to original

Expectation

Calls should be idempotent

Workaround

Not omitting braces

Notes

See also...