IDEA-247781 Unable to toggle sort order of the items in the suggestion list
authorPeter Gromov <peter@jetbrains.com>
Mon, 10 Aug 2020 09:00:21 +0000 (11:00 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 10 Aug 2020 11:23:14 +0000 (11:23 +0000)
GitOrigin-RevId: f7b0c8c6fb2a7ceeed75f876b448d290117b0095

platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java

index 30a3c6f90fe0b5ce7ee86b77058ed2d2c43ef03a..26bdf8e56955e690d2c15b70ddbf8ae6bf7439af 100644 (file)
@@ -337,25 +337,21 @@ class LookupUi {
   }
 
   private final class ChangeSortingAction extends DumbAwareAction implements HintManagerImpl.ActionToIgnore {
-    private boolean sortByName = UISettings.getInstance().getSortLookupElementsLexicographically();
     private ChangeSortingAction() {
       super(ActionsBundle.messagePointer("action.ChangeSortingAction.text"));
     }
 
     @Override
     public void actionPerformed(@NotNull AnActionEvent e) {
-      if (e.getPlace() == ActionPlaces.EDITOR_POPUP) {
-        sortByName = !sortByName;
-
-        FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CHANGE_SORTING);
-        UISettings.getInstance().setSortLookupElementsLexicographically(sortByName);
-        myLookup.resort(false);
-      }
+      FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CHANGE_SORTING);
+      UISettings settings = UISettings.getInstance();
+      settings.setSortLookupElementsLexicographically(!settings.getSortLookupElementsLexicographically());
+      myLookup.resort(false);
     }
 
     @Override
     public void update(@NotNull AnActionEvent e) {
-      e.getPresentation().setIcon(sortByName ? PlatformIcons.CHECK_ICON : null);
+      e.getPresentation().setIcon(UISettings.getInstance().getSortLookupElementsLexicographically() ? PlatformIcons.CHECK_ICON : null);
     }
   }