Fixed selection in case of empty class body

#KT-30597 Fixed
This commit is contained in:
Alexander Podkhalyuzin
2019-03-25 14:21:13 +03:00
parent 29b7da7c49
commit 19f6290686
5 changed files with 17 additions and 1 deletions
@@ -24,7 +24,10 @@ class KotlinClassMemberSelectioner : ExtendWordSelectionHandlerBase() {
val lastChild = parent.lastChild ?: return null
val startElement = firstChild.getNextSiblingIgnoringWhitespace() ?: firstChild
val endElement = lastChild.getPrevSiblingIgnoringWhitespace() ?: lastChild
val textRange = TextRange(startElement.textRange.startOffset, endElement.textRange.endOffset)
val startOffset = startElement.textRange.startOffset
val endOffset = endElement.textRange.endOffset
if (startOffset >= endOffset) return null
val textRange = TextRange(startOffset, endOffset)
return expandToWholeLinesWithBlanks(editorText, textRange)
}
}
+3
View File
@@ -0,0 +1,3 @@
class SimpleClass {
<caret>
}
+3
View File
@@ -0,0 +1,3 @@
class SimpleClass <selection>{
<caret>
}</selection>
+3
View File
@@ -0,0 +1,3 @@
<selection>class SimpleClass {
<caret>
}</selection>
@@ -112,6 +112,10 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase {
doTest();
}
public void testClass() {
doTest();
}
public void testDeclarationWithComment1() { doTest(); }
public void testDeclarationWithComment2() { doTest(); }
public void testDeclarationWithComment3() { doTest(); }