diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt index 11e90bb22dc..a1fcc48494d 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.idea.formatter import com.intellij.formatting.* +import com.intellij.formatting.ChildAttributes.DELEGATE_TO_NEXT_CHILD import com.intellij.lang.ASTNode import com.intellij.psi.TokenType import com.intellij.psi.codeStyle.CodeStyleSettings @@ -195,6 +196,11 @@ abstract class KotlinCommonBlock( } } + if (blocks.size > newChildIndex) { + val block = blocks[newChildIndex] + return ChildAttributes(block.indent, block.alignment) + } + ChildAttributes(Indent.getNoneIndent(), null) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt index 4adfc8f4301..92bd30b81a5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt @@ -603,6 +603,42 @@ class TypedHandlerTest : LightCodeInsightTestCase() { ) } + fun testIndentOnFinishedVariableEndAfterEquals() { + doCharTypeTest( + '\n', + """ + |fun test() { + | val a = + | foo() + |} + """, + """ + |fun test() { + | val a = + | + | foo() + |} + """ + ) + } + + fun testIndentNotFinishedVariableEndAfterEquals() { + doCharTypeTest( + '\n', + """ + |fun test() { + | val a = + |} + """, + """ + |fun test() { + | val a = + | + |} + """ + ) + } + fun testMoveThroughGT() { LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", "val a: List>>")