diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt index 158ef158abd..c5105822604 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinDeclarationSelectioner.kt @@ -55,6 +55,10 @@ class KotlinDeclarationSelectioner : ExtendWordSelectionHandlerBase() { .siblings(forward = false, withItself = true) .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) { val startOffset = minOf( firstComment?.startOffset ?: Int.MAX_VALUE, diff --git a/idea/testData/wordSelection/DeclarationWithDocComment/0.kt b/idea/testData/wordSelection/DeclarationWithDocComment/0.kt new file mode 100644 index 00000000000..7d148d60e16 --- /dev/null +++ b/idea/testData/wordSelection/DeclarationWithDocComment/0.kt @@ -0,0 +1,13 @@ +class C { + fun foo() { + } + + /** + * comment + */ + fun bar() { + } + + fun baz() { + } +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DeclarationWithDocComment/1.kt b/idea/testData/wordSelection/DeclarationWithDocComment/1.kt new file mode 100644 index 00000000000..94a83bffc23 --- /dev/null +++ b/idea/testData/wordSelection/DeclarationWithDocComment/1.kt @@ -0,0 +1,13 @@ +class C { + fun foo() { + } + + /** + * comment + */ + fun bar() { + } + + fun baz() { + } +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DeclarationWithDocComment/2.kt b/idea/testData/wordSelection/DeclarationWithDocComment/2.kt new file mode 100644 index 00000000000..e5aadf7b678 --- /dev/null +++ b/idea/testData/wordSelection/DeclarationWithDocComment/2.kt @@ -0,0 +1,13 @@ +class C { + fun foo() { + } + + /** + * comment + */ + fun bar() { + } + + fun baz() { + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java index 899244ecb32..ae3939e7844 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java @@ -123,6 +123,7 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase { public void testDeclarationWithComment2() { doTest(); } public void testDeclarationWithComment3() { doTest(); } public void testDeclarationWithComment4() { doTest(); } + public void testDeclarationWithDocComment() { doTest(); } public void testLeftBrace() { doTest(); } public void testRightBrace() { doTest(); }