Auto-indent || and && operator typed on a new line (KT-28402)
#KT-28402 Fixed
This commit is contained in:
@@ -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(
|
||||
'.',
|
||||
|
||||
Reference in New Issue
Block a user