diff --git a/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt b/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt index 67ffb52b183..9029841811a 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt @@ -176,11 +176,10 @@ object KeywordCompletion { private fun PsiElement.prevLeafSkipWhitespacesAndComments(): PsiElement? { var leaf = prevLeaf() - while (leaf != null) { - if (leaf !is PsiWhiteSpace && leaf !is PsiComment) return leaf + while (leaf is PsiWhiteSpace || leaf is PsiComment) { leaf = leaf!!.prevLeaf() } - return null + return leaf } // builds text within scope (or from the start of the file) before position element excluding almost all declarations diff --git a/idea/testData/completion/keywords/AfterFuns.kt b/idea/testData/completion/keywords/AfterFuns.kt index c147bc4047c..2f1482b668c 100644 --- a/idea/testData/completion/keywords/AfterFuns.kt +++ b/idea/testData/completion/keywords/AfterFuns.kt @@ -4,7 +4,7 @@ class A { } fun bar() { - fun() + foo() }