diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinTypedHandler.java b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinTypedHandler.java index 1552b69f038..a1ce03cad3c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinTypedHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinTypedHandler.java @@ -44,10 +44,7 @@ import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.KtNodeTypes; import org.jetbrains.kotlin.lexer.KtTokens; -import org.jetbrains.kotlin.psi.KtClassOrObject; -import org.jetbrains.kotlin.psi.KtFile; -import org.jetbrains.kotlin.psi.KtQualifiedExpression; -import org.jetbrains.kotlin.psi.KtSimpleNameStringTemplateEntry; +import org.jetbrains.kotlin.psi.*; public class KotlinTypedHandler extends TypedHandlerDelegate { private final static TokenSet CONTROL_FLOW_EXPRESSIONS = TokenSet.create( @@ -242,7 +239,8 @@ public class KotlinTypedHandler extends TypedHandlerDelegate { } } else if (c == ':') { - if (autoIndentCase(editor, project, file, KtClassOrObject.class)) { + if (autoIndentCase(editor, project, file, KtClassOrObject.class) || + autoIndentCase(editor, project, file, KtOperationReferenceExpression.class)) { return Result.STOP; } } @@ -252,6 +250,7 @@ public class KotlinTypedHandler extends TypedHandlerDelegate { } } + return Result.CONTINUE; } diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt index 6661c8b6232..7d415247b27 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt @@ -584,6 +584,26 @@ class TypedHandlerTest : LightCodeInsightTestCase() { """) } + fun testContinueWithElvis() { + doCharTypeTest( + ':', + """ + |fun test(): Any? = null + |fun some() { + | test() + | ? + |} + """, + """ + |fun test(): Any? = null + |fun some() { + | test() + | ?: + |} + """ + ) + } + fun testSpaceAroundRange() { doCharTypeTest( '.',