mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-61448 Mouse selection in code completion dialog is not recognized
This commit is contained in:
+54
-1
@@ -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<caret>
|
||||
}
|
||||
}
|
||||
""")
|
||||
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<caret>
|
||||
}
|
||||
}
|
||||
""")
|
||||
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<caret>
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-7
@@ -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..<s.size()) {
|
||||
myFixture.type(s.charAt(i))
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void runTest() {
|
||||
@@ -73,7 +75,7 @@ abstract class CompletionAutoPopupTestCase extends LightCodeInsightFixtureTestCa
|
||||
runnable.run()
|
||||
}
|
||||
|
||||
Lookup getLookup() {
|
||||
LookupImpl getLookup() {
|
||||
LookupManager.getActiveLookup(myFixture.getEditor())
|
||||
}
|
||||
|
||||
|
||||
@@ -646,6 +646,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
myList.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e){
|
||||
setFocused(true);
|
||||
markSelectionTouched();
|
||||
|
||||
final Point point = e.getPoint();
|
||||
final int i = myList.locationToIndex(point);
|
||||
@@ -697,6 +698,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
|
||||
public void setCurrentItem(LookupElement item){
|
||||
markSelectionTouched();
|
||||
ListScrollingUtil.selectItem(myList, item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user