Fix ISE in KotlinPairMatcher.getCodeConstructStart()
This commit is contained in:
@@ -44,7 +44,9 @@ class KotlinPairMatcher : PairedBraceMatcher {
|
||||
if (element == null || element is PsiFile) return openingBraceOffset
|
||||
val parent = element.parent
|
||||
return when (parent) {
|
||||
is KtClassBody, is KtBlockExpression -> DeclarationRangeUtil.getDeclarationRange(parent.parent).startOffset
|
||||
is KtClassBody, is KtBlockExpression ->
|
||||
DeclarationRangeUtil.getPossibleDeclarationAtRange(parent.parent)?.startOffset ?: openingBraceOffset
|
||||
|
||||
else -> openingBraceOffset
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,8 @@ class KotlinPairMatcherTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
fun testFun() {
|
||||
doTest("/* Doc comment */ <start>fun xyzzy(x: Int, y: String): Any <brace>{ }")
|
||||
}
|
||||
|
||||
fun testFor() {
|
||||
doTest("fun xyzzy() { for (x in 0..1)<start><brace>{ } }")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user