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 424512ad6f9..877968ef3c0 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -529,6 +529,18 @@ private val INDENT_RULES = arrayOf( } .set(Indent.getNormalIndent()), + strategy("Property initializer") + .within(KtNodeTypes.PROPERTY) + .forElement { + it.psi is KtExpression + } + .set { settings -> + if (settings.kotlinCustomSettings.CONTINUATION_INDENT_FOR_EXPRESSION_BODIES) + Indent.getContinuationWithoutFirstIndent() + else + Indent.getNormalIndent() + }, + strategy("Indent for parts") .within(KtNodeTypes.PROPERTY, KtNodeTypes.FUN, KtNodeTypes.DESTRUCTURING_DECLARATION, KtNodeTypes.SECONDARY_CONSTRUCTOR) .notForType(KtNodeTypes.BLOCK, FUN_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, CONSTRUCTOR_KEYWORD, KtTokens.RPAR) diff --git a/idea/testData/formatter/PropertyInitializerLineBreak.after.kt b/idea/testData/formatter/PropertyInitializerLineBreak.after.kt index f5b73e7faec..e955975d155 100644 --- a/idea/testData/formatter/PropertyInitializerLineBreak.after.kt +++ b/idea/testData/formatter/PropertyInitializerLineBreak.after.kt @@ -1,6 +1,11 @@ val x: Int = 1 +val y: Int = + 2 + fun foo() = 1 fun bar() = 1 + +// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES diff --git a/idea/testData/formatter/PropertyInitializerLineBreak.kt b/idea/testData/formatter/PropertyInitializerLineBreak.kt index c2f3752f400..b2a841901a9 100644 --- a/idea/testData/formatter/PropertyInitializerLineBreak.kt +++ b/idea/testData/formatter/PropertyInitializerLineBreak.kt @@ -1,8 +1,13 @@ val x: Int - = 1 + = 1 + +val y: Int = + 2 fun foo() - = 1 + = 1 fun bar() = 1 + +// SET_FALSE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES