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:
+1
-1
@@ -44,8 +44,8 @@ public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() {
|
|||||||
val start = findBlockContentStart(node)
|
val start = findBlockContentStart(node)
|
||||||
val end = findBlockContentEnd(node, start)
|
val end = findBlockContentEnd(node, start)
|
||||||
|
|
||||||
result.add(e.getTextRange()!!)
|
|
||||||
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(start, end)))
|
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(start, end)))
|
||||||
|
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, e.getTextRange()!!))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ package org.jetbrains.jet.plugin.editor.wordSelection
|
|||||||
|
|
||||||
import com.intellij.openapi.util.Condition
|
import com.intellij.openapi.util.Condition
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetContainerNode
|
||||||
|
|
||||||
public class KotlinWordSelectionFilter : Condition<PsiElement>{
|
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
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) {
|
||||||
|
<caret>f()
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) {
|
||||||
|
<selection><caret>f</selection>()
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) {
|
||||||
|
<selection><caret>f()</selection>
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) {
|
||||||
|
<selection> <caret>f()
|
||||||
|
</selection> g()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) {
|
||||||
|
<selection> <caret>f()
|
||||||
|
g()
|
||||||
|
</selection> }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
if (a) <selection>{
|
||||||
|
<caret>f()
|
||||||
|
g()
|
||||||
|
}</selection>
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo() {
|
||||||
|
<selection> if (a) {
|
||||||
|
<caret>f()
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
</selection>}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
for (i in 1..100) {
|
for (i in 1..100) {
|
||||||
<selection>when {
|
<selection> when {
|
||||||
i%3 == 0 -> {print("Fizz"); continue;}
|
i%3 == 0 -> {print("Fizz"); continue;}
|
||||||
i%5 == 0 -> {print("Buzz"); continue;}
|
i%5 == 0 -> {print("Buzz"); continue;}
|
||||||
|
|
||||||
(i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret>
|
(i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret>
|
||||||
else -> println()
|
else -> println()
|
||||||
}</selection>
|
}
|
||||||
}
|
</selection> }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo() : Unit {
|
fun foo() : Unit {
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class WordSelectionTest extends JetLightCodeInsightFixtureTestCase {
|
|||||||
|
|
||||||
public void testSimpleComment() { doTest(); }
|
public void testSimpleComment() { doTest(); }
|
||||||
|
|
||||||
|
public void testIfBody() { doTest(); }
|
||||||
|
|
||||||
private void doTest() {
|
private void doTest() {
|
||||||
String dirName = getTestName(false);
|
String dirName = getTestName(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user