Extend selection: select just KDoc if cursor is just before the KDoc (KT-16476)
#KT-16476 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
8afa938723
commit
c442d69db6
+4
@@ -55,6 +55,10 @@ class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() {
|
|||||||
.siblings(forward = false, withItself = true)
|
.siblings(forward = false, withItself = true)
|
||||||
.first { it !is PsiComment && it !is PsiWhiteSpace }
|
.first { it !is PsiComment && it !is PsiWhiteSpace }
|
||||||
|
|
||||||
|
if (firstComment != null && cursorOffset <= firstComment.startOffset) {
|
||||||
|
result.addRange(editorText, TextRange(firstComment.startOffset, firstComment.endOffset))
|
||||||
|
}
|
||||||
|
|
||||||
if (firstComment != null || lastComment != null) {
|
if (firstComment != null || lastComment != null) {
|
||||||
val startOffset = minOf(
|
val startOffset = minOf(
|
||||||
firstComment?.startOffset ?: Int.MAX_VALUE,
|
firstComment?.startOffset ?: Int.MAX_VALUE,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class C {
|
||||||
|
fun foo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
<caret> /**
|
||||||
|
* comment
|
||||||
|
*/
|
||||||
|
fun bar() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun baz() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class C {
|
||||||
|
fun foo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
<selection><caret> /**
|
||||||
|
* comment
|
||||||
|
*/
|
||||||
|
</selection> fun bar() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun baz() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class C {
|
||||||
|
fun foo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
<selection><caret> /**
|
||||||
|
* comment
|
||||||
|
*/
|
||||||
|
fun bar() {
|
||||||
|
}
|
||||||
|
</selection>
|
||||||
|
fun baz() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,7 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase {
|
|||||||
public void testDeclarationWithComment2() { doTest(); }
|
public void testDeclarationWithComment2() { doTest(); }
|
||||||
public void testDeclarationWithComment3() { doTest(); }
|
public void testDeclarationWithComment3() { doTest(); }
|
||||||
public void testDeclarationWithComment4() { doTest(); }
|
public void testDeclarationWithComment4() { doTest(); }
|
||||||
|
public void testDeclarationWithDocComment() { doTest(); }
|
||||||
|
|
||||||
public void testLeftBrace() { doTest(); }
|
public void testLeftBrace() { doTest(); }
|
||||||
public void testRightBrace() { doTest(); }
|
public void testRightBrace() { doTest(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user