scala-ide / scalariform

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

Not enough indents for trailing methods without parameters #222

Closed acjay closed 7 years ago

acjay commented 8 years ago

Nested multi-line method calls trailed with a no-params method call are un-indented. If the training method is called with zero-params, it yields different (correct) behavior. If there are no trailing methods, the behavior is also as expected.

trait ScalariformTest {
  def goodExample1(arg1: Int, arg2: Int): Int

  def foo(arg1: Int, arg2: Int): Int

  goodExample1(
    foo(
      1,
      2
    ),
    foo(
      3,
      4
    )
  )

  def goodExample2(arg1: Int, arg2: Int): Int

  case class Bar(arg1: Int, arg2: Int) {
    def value(): Int = arg1
  }

  goodExample2(
    Bar(
      1,
      2
    ).value(),
    Bar(
      3,
      4
    ).value()
  )

  def badExample(arg1: Int, arg2: Int): Int

  case class Foo(arg1: Int, arg2: Int) {
    def value: Int = arg1
  }

  badExample(
    Foo(
      1,
      2
    ).value,
    Foo(
      3,
      4
    ).value
  )
}

The following is with the sbt-scalariform preferences:

ScalariformKeys.preferences := ScalariformKeys.preferences.value
  .setPreference(AlignArguments, true)
  .setPreference(AlignParameters, true)
  .setPreference(AlignSingleLineCaseStatements, true)
  .setPreference(DoubleIndentClassDeclaration, false)
jkinkead commented 8 years ago

It's not clear to me if the badExample call is meant to be incorrectly-formatted - it looks correct to me. Is the badExample in your code how you'd like the code to be formatted?

godenji commented 7 years ago

LGTM in 0.2.4, or maybe badExample is supposed to have different formatting? Closing, re-open if necessary.