IDEA-84754 Completion preselect the specified value if it is selected in editor

This commit is contained in:
peter
2012-04-25 22:12:41 +02:00
parent bb18a176a5
commit 0b7b3518ad
3 changed files with 16 additions and 1 deletions
@@ -0,0 +1,7 @@
public class FooBar {
int a() {
<caret><selection>finalize</selection>
}
}
@@ -632,6 +632,12 @@ public class ListUtils {
public void testQualifierAsPackage3() throws Throwable {
doTest();
}
public void testPreselectEditorSelection() {
configure()
assert lookup.currentItem != myFixture.lookupElements[0]
assert 'finalize' == lookup.currentItem.lookupString
}
public void testPackageNamedVariableBeforeAssignment() throws Throwable {
doTest();
@@ -215,9 +215,11 @@ public class CompletionLookupArranger extends LookupArranger {
}
}
String selectedText = lookup.getEditor().getSelectionModel().getSelectedText();
for (int i = 0; i < items.size(); i++) {
LookupElement item = items.get(i);
if (isPrefixItem(lookup, item, true) && !isLiveTemplate(item)) {
if (isPrefixItem(lookup, item, true) && !isLiveTemplate(item) ||
item.getLookupString().equals(selectedText)) {
return i;
}
}