diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index dab20f656490..0a10b0391fa5 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -335,6 +335,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement ApplicationManager.getApplication().assertIsDispatchThread(); if (isOutdated()) return; + boolean justShown = false; if (!myLookup.isShown() && (!isAutopopupCompletion() || !myLookup.isCalculating())) { if (hideAutopopupIfMeaningless()) { return; @@ -348,10 +349,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } myLookup.show(); + justShown = true; } myLookup.refreshUi(); hideAutopopupIfMeaningless(); updateFocus(); + if (justShown) { + myLookup.ensureSelectionVisible(); + } } final boolean isInsideIdentifier() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index fcd321037957..081c83094841 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -347,7 +347,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable myStartCompletionWhenNothingMatches = startCompletionWhenNothingMatches; } - private void ensureSelectionVisible() { + public void ensureSelectionVisible() { ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1); } @@ -493,7 +493,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable if (choosePreselectedItem) { myList.setSelectedValue(myPreselectedItem, false); } else { - ListScrollingUtil.selectItem(myList, doSelectMostPreferableItem(getItems(), groups)); + myList.setSelectedIndex(doSelectMostPreferableItem(getItems(), groups)); } if (myPreselectedItem != null && myShown) {