diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java index de5bd23a4c9..e0cff74bebf 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java @@ -168,8 +168,12 @@ public class JetBlock extends AbstractBlock { return super.getChildAttributes(newChildIndex); } - if (isIncomplete()) { - return super.getChildAttributes(newChildIndex); + List blocks = getSubBlocks(); + if (newChildIndex != 0) { + boolean isIncomplete = newChildIndex < blocks.size() ? blocks.get(newChildIndex - 1).isIncomplete() : isIncomplete(); + if (isIncomplete) { + return super.getChildAttributes(newChildIndex); + } } return new ChildAttributes(Indent.getNoneIndent(), null); diff --git a/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt b/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt new file mode 100644 index 00000000000..8677ec04fe9 --- /dev/null +++ b/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt @@ -0,0 +1,4 @@ +class A() + + +fun \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt b/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt new file mode 100644 index 00000000000..ee996f5dd70 --- /dev/null +++ b/idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt @@ -0,0 +1,3 @@ +class A() + +fun \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java index 409c72f79af..cb5a97f7c26 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java @@ -40,6 +40,11 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde doNewlineTest("idea/testData/indentationOnNewline/AfterCatch.after.kt"); } + @TestMetadata("AfterClassNameBeforeFun.after.kt") + public void testAfterClassNameBeforeFun() throws Exception { + doNewlineTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt"); + } + @TestMetadata("AfterFinally.after.kt") public void testAfterFinally() throws Exception { doNewlineTest("idea/testData/indentationOnNewline/AfterFinally.after.kt");