Braces placement
Hello all,
I recently switched to IDEA (from Eclipse) and am quite happy with the IDE and Scala plugin. There is one annoying thing however:
I prefer putting opening braces on the next line (I know it is non-idiomatic). After typing the opening-brace and pressing enter the editor autmatically inserts the closing brace. So far so good.
But often the editor will also indent the pair of braces instead of lining them up with the previous line. In fact, I think that every time the previous line does not end in a closing bracket the braces are indented. This is NEVER what I want but I can not find any setting that prevents this behavior.
Please tell me something can be done about this...
Please sign in to leave a comment.
Please, provide a code snippet with the explanation of how to reproduce the misbehavior (I've tried hard, but everything seems to be OK).
Check "Settings / Code Style / Wrapping and Braces / Braces placement" section.
Hello Pavel,
Try entering this:
val n = Seq(1,2,3)
n.foreach
{
x =>
{
println(x)
}
}
I know it is a completely bloated example but even only entering "n.foreach<CR>{" produces the unexpected indent of the open brace.
I have set all braces to "next line" and have even tried setting the continuation indent to 0 but this setting does not seem to have any influence on my autoindenting at all.
It appears other people have run into this issue as well. Disturbingly http://youtrack.jetbrains.net/issue/SCL-2066 seems to suggest Alexander thinks this issue has been fixed, which is not true at all.
I tried all possible values for those settings but the behavior stays the same. The resulting layout (sometimes one indent level too many, usually two levels) makes no sense at all, regardless what settings you use.
I am using tabs for indenting.
Silvio
I added fix for your case. Please try next nightly build. If something more is wrong please report it. ("Brace Placement -> Other -> Next Line" should work now) Thenk you for your example.
Best regards,
Alexander Podkhalyuzin.
Hello Alexander,
I just installed the latest build and can confirm that the problem has been fixed.
Thank you very much.
Cheers,
Silvio
Thanks for fixing that :) I really like it this way …
def allFine() =
{
"foo"
}
However it fails for def when followed by ensuring:
def notFine() =
{
"bar"
} ensuring (_ != "foo")
Any idea how to get the rid of the indentation in this case?
addition: reported …