diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 50cebfb33bf..c149041b888 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -399,20 +399,16 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing inPosition(parent = FUNCTION_LITERAL, left = LBRACE) - .customRule { - _, _, right -> + .customRule { _, _, right -> val rightNode = right.node!! val rightType = rightNode.elementType - var numSpaces = spacesInSimpleFunction + val numSpaces = spacesInSimpleFunction if (rightType == VALUE_PARAMETER_LIST) { - val firstParamListNode = rightNode.firstChildNode - if (firstParamListNode != null && firstParamListNode.elementType == LPAR) { - // Don't put space for situation {(a: Int) -> a } - numSpaces = 0 - } + createSpacing(numSpaces, keepLineBreaks = false) + } + else { + createSpacing(numSpaces) } - - createSpacing(numSpaces) } inPosition(parent = CLASS_BODY, right = RBRACE).lineBreakIfLineBreakInParent(numSpacesOtherwise = 1) diff --git a/idea/testData/formatter/BinaryExpressionAlignmentSpread.after.kt b/idea/testData/formatter/BinaryExpressionAlignmentSpread.after.kt index ca13118db74..5cddef572a1 100644 --- a/idea/testData/formatter/BinaryExpressionAlignmentSpread.after.kt +++ b/idea/testData/formatter/BinaryExpressionAlignmentSpread.after.kt @@ -7,8 +7,7 @@ fun test() { } } - 2 ?: some { - s -> + 2 ?: some { s -> val a = 12 } } diff --git a/idea/testData/intentions/destructuringInLambda/noItVariables.kt.after b/idea/testData/intentions/destructuringInLambda/noItVariables.kt.after index 5bc011c2388..0024f4c1a0b 100644 --- a/idea/testData/intentions/destructuringInLambda/noItVariables.kt.after +++ b/idea/testData/intentions/destructuringInLambda/noItVariables.kt.after @@ -4,7 +4,6 @@ data class XY(val x: String, val y: String) fun convert(xy: XY, foo: (XY) -> Unit) = foo(xy) -fun foo(xy: XY) = convert(xy) { - (x, y) -> +fun foo(xy: XY) = convert(xy) { (x, y) -> println(x + y) } \ No newline at end of file diff --git a/idea/testData/intentions/destructuringInLambda/noItWithDestructuring.kt.after b/idea/testData/intentions/destructuringInLambda/noItWithDestructuring.kt.after index 7dfd536c73c..41cc506ee9d 100644 --- a/idea/testData/intentions/destructuringInLambda/noItWithDestructuring.kt.after +++ b/idea/testData/intentions/destructuringInLambda/noItWithDestructuring.kt.after @@ -2,7 +2,6 @@ data class XY(val x: String, val y: String) fun convert(xy: XY, foo: (XY) -> String) = foo(xy) -fun foo(xy: XY) = convert(xy) { - (x, y) -> +fun foo(xy: XY) = convert(xy) { (x, y) -> x + y } \ No newline at end of file diff --git a/idea/testData/intentions/specifyExplicitLambdaSignature/emptyParamListWithWhiteSpace.kt.after b/idea/testData/intentions/specifyExplicitLambdaSignature/emptyParamListWithWhiteSpace.kt.after index e26175c20b7..c9ddc95b4b4 100644 --- a/idea/testData/intentions/specifyExplicitLambdaSignature/emptyParamListWithWhiteSpace.kt.after +++ b/idea/testData/intentions/specifyExplicitLambdaSignature/emptyParamListWithWhiteSpace.kt.after @@ -1,6 +1,5 @@ fun main() { - val oom: (Int)->Int = { - it: Int -> + val oom: (Int)->Int = { it: Int -> it * 2 } } \ No newline at end of file diff --git a/idea/testData/intentions/specifyExplicitLambdaSignature/manyNewlines.kt.after b/idea/testData/intentions/specifyExplicitLambdaSignature/manyNewlines.kt.after index 614881f168c..4b9626c9d4e 100644 --- a/idea/testData/intentions/specifyExplicitLambdaSignature/manyNewlines.kt.after +++ b/idea/testData/intentions/specifyExplicitLambdaSignature/manyNewlines.kt.after @@ -1,5 +1,4 @@ -val foo: (Long) -> String = { - it: Long -> +val foo: (Long) -> String = { it: Long -> it.toString() diff --git a/idea/testData/refactoring/inline/inlineVariableOrProperty/explicateParameterTypes/ItMultiLine.kt.after b/idea/testData/refactoring/inline/inlineVariableOrProperty/explicateParameterTypes/ItMultiLine.kt.after index 9a673a154e4..76f5702e37b 100644 --- a/idea/testData/refactoring/inline/inlineVariableOrProperty/explicateParameterTypes/ItMultiLine.kt.after +++ b/idea/testData/refactoring/inline/inlineVariableOrProperty/explicateParameterTypes/ItMultiLine.kt.after @@ -1,6 +1,5 @@ fun foo() { - val ff = { - it: Int -> + val ff = { it: Int -> it } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt index c47d98ca51d..e6cdd017517 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt @@ -986,13 +986,11 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { fun testInLambda2() = doFunTest( """ - some { - p -> + some { p -> } """, """ - some { - p -> + some { p -> } """ @@ -1000,13 +998,11 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { fun testInLambda3() = doFunTest( """ - some { - (p: Int) : Int -> + some { (p: Int) : Int -> } """, """ - some { - (p: Int) : Int -> + some { (p: Int) : Int -> } """