check lookup element presentation from previous completion to preserve selection...
authorpeter <peter@jetbrains.com>
Mon, 16 Nov 2015 16:07:34 +0000 (17:07 +0100)
committerpeter <peter@jetbrains.com>
Mon, 16 Nov 2015 16:08:34 +0000 (17:08 +0100)
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java

index 87ce27cfa00b1ee30b6a9f5a5e97c5939da7a9d1..122967f09e88f3eaf476cf1696e09bbfd2adba4a 100644 (file)
@@ -51,6 +51,7 @@ public class CompletionLookupArranger extends LookupArranger {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionLookupArranger");
   @Nullable private static StatisticsUpdate ourPendingUpdate;
   private static final Alarm ourStatsAlarm = new Alarm(ApplicationManager.getApplication());
+  private static final Key<String> GLOBAL_PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
   private final Key<String> PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
   private final Comparator<LookupElement> BY_PRESENTATION_COMPARATOR = new Comparator<LookupElement>() {
     @Override
@@ -152,6 +153,7 @@ public class CompletionLookupArranger extends LookupArranger {
 
     final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
     element.putUserData(PRESENTATION_INVARIANT, invariant);
+    element.putUserData(GLOBAL_PRESENTATION_INVARIANT, invariant);
 
     CompletionSorterImpl sorter = obtainSorter(element);
     Classifier<LookupElement> classifier = myClassifiers.get(sorter);
@@ -391,7 +393,7 @@ public class CompletionLookupArranger extends LookupArranger {
 
       for (int i = 0; i < items.size(); i++) {
         String invariant = PRESENTATION_INVARIANT.get(items.get(i));
-        if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) {
+        if (invariant != null && invariant.equals(GLOBAL_PRESENTATION_INVARIANT.get(lastSelection))) {
           return i;
         }
       }