diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index c16733b9b954..0192d0e38292 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -17,7 +17,7 @@ package com.intellij.codeInsight.completion import com.intellij.openapi.actionSystem.IdeActions -/** + /** * @author peter */ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { @@ -96,6 +96,28 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } + public void testExplicitMouseSelectionShouldSurvive() { + myFixture.configureByText("a.java", """ + class Foo { + void foo(String iterable) { + int iterable2; + it + } + } + """) + type "e" + assertOrderedEquals myFixture.lookupElementStrings, "iterable", "iterable2" + + assertEquals 'iterable', lookup.currentItem.lookupString + lookup.currentItem = lookup.items[1] + assertEquals 'iterable2', lookup.currentItem.lookupString + + type "r" + assertOrderedEquals myFixture.lookupElementStrings, "iter", "iterable", 'iterable2' + assertEquals 'iterable2', lookup.currentItem.lookupString + + } + public void testNoAutopopupInTheMiddleOfIdentifier() { myFixture.configureByText("a.java", """ class Foo { @@ -142,4 +164,35 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertNull lookup } + public void testExplicitSelectionShouldBeHonoredFocused() { + myFixture.configureByText("a.java", """ + class Foo { + String foo() { + int abcd; + int abce; + a + } + } + """) + type 'b' + assert lookup.focused + type 'c' + + assertOrderedEquals myFixture.lookupElementStrings, 'abcd', 'abce' + assertEquals 'abcd', lookup.currentItem.lookupString + lookup.currentItem = lookup.items[1] + assertEquals 'abce', lookup.currentItem.lookupString + + type '\t' + myFixture.checkResult """ + class Foo { + String foo() { + int abcd; + int abce; + abce + } + } + """ + } + } diff --git a/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy b/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy index 27c7c935c050..66140eaddb79 100644 --- a/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy +++ b/java/testFramework/src/com/intellij/codeInsight/completion/CompletionAutoPopupTestCase.groovy @@ -16,12 +16,12 @@ package com.intellij.codeInsight.completion import com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler -import com.intellij.codeInsight.lookup.Lookup import com.intellij.codeInsight.lookup.LookupManager -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import com.intellij.util.ui.UIUtil +import com.intellij.codeInsight.lookup.impl.LookupImpl import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.ui.UIUtil /** * @author peter @@ -56,9 +56,11 @@ abstract class CompletionAutoPopupTestCase extends LightCodeInsightFixtureTestCa } void type(String s) { - myFixture.type(s) - ApplicationManager.application.invokeAndWait({ println "wait1" } as Runnable, ModalityState.NON_MODAL) // for the autopopup's alarm - ApplicationManager.application.invokeAndWait({ println "wait2" } as Runnable, ModalityState.NON_MODAL) // for the restartCompletion's invokeLater + for (i in 0..