derekwyatt/vim-scala

for loop with multiline iteration has incorrect indention for closing brace

tmccombs opened this issue · 1 comments

If the iteration part of a for loop is multiple lines, for example:

for {
  a <- b
  c <- d
} yield {
   // body
}

then when I type the second opening brace (after yield) it iwll indent the line so the first closing brace lines up with the line before, like:

for {
  a <- b
  c <- d
  } yield {

The same thing happens if the yield isn't there. Strangely , if I don't have the second opening brace the line with the closing brace indents correctly.

this also happens for function definitions, i.e. should do:

def foo(
  i: Int,
  j: Int,
): Int = {
  // body
}

but actually does:

def foo(
  i: Int,
  j: Int,
  ): Int = {
  // body
}

In fact, the exact same problem also exists for function calls, not only function definitions. I.e., it does this:

foo(
  1,
  2,
  ) // should not be indented

I went ahead and looked at indent/scala.vim to propose a fix, but vimscript man... helluva language