Fixed KT-5894 Select Woes: no need to select code block + end of line

+ corrected selection of when

 #KT-5894 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-12-15 20:11:54 -07:00
parent 5f9e685188
commit 3059a46ca7
11 changed files with 52 additions and 5 deletions
@@ -44,8 +44,8 @@ public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() {
val start = findBlockContentStart(node)
val end = findBlockContentEnd(node, start)
result.add(e.getTextRange()!!)
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(start, end)))
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.getTextRange()!!))
return result
}
@@ -18,7 +18,10 @@ package org.jetbrains.jet.plugin.editor.wordSelection
import com.intellij.openapi.util.Condition
import com.intellij.psi.PsiElement
import org.jetbrains.jet.lang.psi.JetBlockExpression
import org.jetbrains.jet.lang.psi.JetContainerNode
public class KotlinWordSelectionFilter : Condition<PsiElement>{
override fun value(e: PsiElement) = !KotlinListSelectioner.canSelect(e)
override fun value(e: PsiElement)
= !KotlinListSelectioner.canSelect(e) && e !is JetBlockExpression && e !is JetContainerNode
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) {
<caret>f()
g()
}
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) {
<selection><caret>f</selection>()
g()
}
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) {
<selection><caret>f()</selection>
g()
}
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) {
<selection> <caret>f()
</selection> g()
}
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) {
<selection> <caret>f()
g()
</selection> }
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
if (a) <selection>{
<caret>f()
g()
}</selection>
}
+6
View File
@@ -0,0 +1,6 @@
fun foo() {
<selection> if (a) {
<caret>f()
g()
}
</selection>}
+3 -3
View File
@@ -1,13 +1,13 @@
fun main(args : Array<String>) {
for (i in 1..100) {
<selection>when {
<selection> when {
i%3 == 0 -> {print("Fizz"); continue;}
i%5 == 0 -> {print("Buzz"); continue;}
(i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret>
else -> println()
}</selection>
}
}
</selection> }
}
fun foo() : Unit {
@@ -45,6 +45,8 @@ public class WordSelectionTest extends JetLightCodeInsightFixtureTestCase {
public void testSimpleComment() { doTest(); }
public void testIfBody() { doTest(); }
private void doTest() {
String dirName = getTestName(false);