scala-ide / scalariform

Scala source code formatter
http://scala-ide.github.com/scalariform/
MIT License
527 stars 148 forks source link

Arguments of nested anonymous functions are crammed into a single line #269

Open odisseus opened 6 years ago

odisseus commented 6 years ago

When I have an anonymous function that returns another anonymous function, I would like to keep the arguments of each consecutive layer in a separate line. However, Scalariform moves them all into a single line, and I could not find a configuration key to change this behaviour.

Here's an example:

Before:

object Main {
  def foo: Int => Int => String = {
    x: Int =>
      y: Int =>
        "x"
  }
}

After:

object Main {
  def foo: Int => Int => String = { x: Int => y: Int =>
    "x"
  }
}

This issue may be similar to #21, but it is not a duplicate. In particular, the example from #21 is not being reformatted.

I use SBT 1.1.1 with Scala 2.12.4 and sbt-scalariform 1.8.2 with scalariform 0.2.5.

It seems that the change that breaks my example has been deliberately introduced by commit 34a7bbde77b83455e0b511ac4055b4aa0c754a46.

odisseus commented 6 years ago

Update: The old version I was comparing against is in fact older than 0.1.7. I tracked the breaking change to commit 34a7bbde77b83455e0b511ac4055b4aa0c754a46.