Better indentation for expressions without parsed errors (KT-12123)
#KT-12123 Fixed
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.formatter
|
package org.jetbrains.kotlin.idea.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.*
|
||||||
|
import com.intellij.formatting.ChildAttributes.DELEGATE_TO_NEXT_CHILD
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
import com.intellij.psi.TokenType
|
import com.intellij.psi.TokenType
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
@@ -195,6 +196,11 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blocks.size > newChildIndex) {
|
||||||
|
val block = blocks[newChildIndex]
|
||||||
|
return ChildAttributes(block.indent, block.alignment)
|
||||||
|
}
|
||||||
|
|
||||||
ChildAttributes(Indent.getNoneIndent(), null)
|
ChildAttributes(Indent.getNoneIndent(), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,6 +603,42 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testIndentOnFinishedVariableEndAfterEquals() {
|
||||||
|
doCharTypeTest(
|
||||||
|
'\n',
|
||||||
|
"""
|
||||||
|
|fun test() {
|
||||||
|
| val a =<caret>
|
||||||
|
| foo()
|
||||||
|
|}
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
|fun test() {
|
||||||
|
| val a =
|
||||||
|
| <caret>
|
||||||
|
| foo()
|
||||||
|
|}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testIndentNotFinishedVariableEndAfterEquals() {
|
||||||
|
doCharTypeTest(
|
||||||
|
'\n',
|
||||||
|
"""
|
||||||
|
|fun test() {
|
||||||
|
| val a =<caret>
|
||||||
|
|}
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
|fun test() {
|
||||||
|
| val a =
|
||||||
|
| <caret>
|
||||||
|
|}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun testMoveThroughGT() {
|
fun testMoveThroughGT() {
|
||||||
LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", "val a: List<Set<Int<caret>>>")
|
LightPlatformCodeInsightTestCase.configureFromFileText("a.kt", "val a: List<Set<Int<caret>>>")
|
||||||
|
|||||||
Reference in New Issue
Block a user