Ctrl-W works badly for selecting body of multi-line lambda starting with comment (KT-9014)
#KT-9014 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
3d5c499773
commit
df28d34f0f
+2
-5
@@ -21,15 +21,12 @@ import com.intellij.openapi.util.TextRange
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||||
import org.jetbrains.kotlin.psi.JetBlockExpression
|
|
||||||
import org.jetbrains.kotlin.psi.JetExpression
|
|
||||||
import org.jetbrains.kotlin.psi.JetWhenEntry
|
|
||||||
import org.jetbrains.kotlin.psi.JetWhenExpression
|
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
|
|
||||||
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
|
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||||
import com.intellij.psi.PsiComment
|
import com.intellij.psi.PsiComment
|
||||||
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Originally from IDEA platform: StatementGroupSelectioner
|
* Originally from IDEA platform: StatementGroupSelectioner
|
||||||
@@ -38,7 +35,7 @@ public class KotlinStatementGroupSelectioner : ExtendWordSelectionHandlerBase()
|
|||||||
override fun canSelect(e: PsiElement): Boolean {
|
override fun canSelect(e: PsiElement): Boolean {
|
||||||
if (e !is JetExpression && e !is JetWhenEntry && e !is PsiComment) return false
|
if (e !is JetExpression && e !is JetWhenEntry && e !is PsiComment) return false
|
||||||
val parent = e.getParent()
|
val parent = e.getParent()
|
||||||
return parent is JetBlockExpression || parent is JetWhenExpression
|
return parent is JetBlockExpression || parent is JetWhenExpression || parent is JetFunctionLiteral
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
|
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run {
|
||||||
|
// test
|
||||||
|
<caret>1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run {
|
||||||
|
// test
|
||||||
|
<selection><caret>1</selection>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run {
|
||||||
|
// test
|
||||||
|
<selection> <caret>1
|
||||||
|
</selection> }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run {
|
||||||
|
<selection> // test
|
||||||
|
<caret>1
|
||||||
|
</selection> }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run <selection>{
|
||||||
|
// test
|
||||||
|
<caret>1
|
||||||
|
}</selection>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
run <selection>{
|
||||||
|
// test
|
||||||
|
<caret>1
|
||||||
|
}
|
||||||
|
</selection>}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun run(f: () -> Unit) = 1
|
||||||
|
fun test() {
|
||||||
|
<selection> run {
|
||||||
|
// test
|
||||||
|
<caret>1
|
||||||
|
}
|
||||||
|
</selection>}
|
||||||
@@ -59,6 +59,8 @@ public class WordSelectionTest extends JetLightCodeInsightFixtureTestCase {
|
|||||||
|
|
||||||
public void testCommentForStatements() { doTest(); }
|
public void testCommentForStatements() { doTest(); }
|
||||||
|
|
||||||
|
public void testCommentForStatementsInLambda() { doTest(); }
|
||||||
|
|
||||||
public void testSimpleStringLiteral() { doTest(); }
|
public void testSimpleStringLiteral() { doTest(); }
|
||||||
public void testSimpleStringLiteral2() { doTest(); }
|
public void testSimpleStringLiteral2() { doTest(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user