ThorinII
ThorinII

Reputation: 193

Format partial functions like match functions in Scala with IntelliJ

IntelliJ (14.0.3, Scala plugin 1.4) formats regular case/match blocks after a function as so (this is from some HTTP code):

get("/work") { x => x match {
  case (200, result) => ...
  case _ => ...
}
             } // I'm not worried about this brace

If I collapse that obvious x => x match, it formats it like this:

get("/work") {
               case (200, result) => ...
               case _ => ...
             }

That kind of formatting gets messy if the call to get("/work") uses a longer url (as I have in places). It gets even worse if I have further nested things.

Is there any way to make IntelliJ format the case statements to be indented by one tabstop relative to the original statement, instead of relative to the opening brace?

Upvotes: 0

Views: 223

Answers (1)

ThorinII
ThorinII

Reputation: 193

Turns out, it's a matter of setting the right code-style options.

In Settings -> Editor -> Code Style -> Scala, Wrapping and Braces -> Method call arguments, Do not align block expression parameters must be on, if Align when multiline is on.

Upvotes: 1

Related Questions