diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetFormattingModelBuilder.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetFormattingModelBuilder.java index afcb90f39b0..58082979744 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetFormattingModelBuilder.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetFormattingModelBuilder.java @@ -106,7 +106,10 @@ public class JetFormattingModelBuilder implements FormattingModelBuilder { .afterInside(COLON, TYPE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_EXTEND_COLON) .between(VALUE_ARGUMENT_LIST, FUNCTION_LITERAL_EXPRESSION).spaces(1) + + //when .aroundInside(ARROW, WHEN_ENTRY).spaceIf(jetSettings.SPACE_AROUND_WHEN_ARROW) + .beforeInside(LBRACE, WHEN).spacing(1, 1, 0, true, 0) //omit blank lines before '{' in 'when' statement ; } diff --git a/idea/testData/formatter/WhenLinesBeforeLbrace.kt b/idea/testData/formatter/WhenLinesBeforeLbrace.kt new file mode 100644 index 00000000000..f5da9262b2f --- /dev/null +++ b/idea/testData/formatter/WhenLinesBeforeLbrace.kt @@ -0,0 +1,17 @@ +fun f(x: Any): Int { + return when (x) + + + + + + + + + + + { + is Int->1 + else->0 + } +} \ No newline at end of file diff --git a/idea/testData/formatter/WhenLinesBeforeLbrace_after.kt b/idea/testData/formatter/WhenLinesBeforeLbrace_after.kt new file mode 100644 index 00000000000..1d9ad0a982d --- /dev/null +++ b/idea/testData/formatter/WhenLinesBeforeLbrace_after.kt @@ -0,0 +1,7 @@ +fun f(x: Any): Int { + return when (x) + { + is Int -> 1 + else -> 0 + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java index 95afa1cbd09..d36151e3066 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java @@ -135,6 +135,10 @@ public class JetFormatterTest extends AbstractJetFormatterTest { doTestWithInvert(); } + public void testWhenLinesBeforeLbrace() throws Exception { + doTest(); + } + @Override public void doTest() throws Exception { String originalFileText = AbstractJetFormatterTest.loadFile(getTestName(false) + ".kt");