Auto-indent || and && operator typed on a new line (KT-28402)

#KT-28402 Fixed
This commit is contained in:
Nikolay Krasko
2018-11-23 14:48:22 +03:00
parent 9c41ec46ee
commit bc6f53d023
2 changed files with 45 additions and 1 deletions
@@ -249,7 +249,15 @@ public class KotlinTypedHandler extends TypedHandlerDelegate {
return Result.STOP;
}
}
else if (c == '|') {
if (autoIndentCase(editor, project, file, KtOperationReferenceExpression.class)) {
return Result.STOP;
}
} else if (c == '&') {
if (autoIndentCase(editor, project, file, KtOperationReferenceExpression.class)) {
return Result.STOP;
}
}
return Result.CONTINUE;
}
@@ -604,6 +604,42 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
)
}
fun testContinueWithOr() {
doCharTypeTest(
'|',
"""
|fun some() {
| if (true
| |<caret>)
|}
""",
"""
|fun some() {
| if (true
| ||<caret>)
|}
"""
)
}
fun testContinueWithAnd() {
doCharTypeTest(
'&',
"""
|fun some() {
| val test = true
| &<caret>
|}
""",
"""
|fun some() {
| val test = true
| &&<caret>
|}
"""
)
}
fun testSpaceAroundRange() {
doCharTypeTest(
'.',