From 357cee2b127e7c43a275bdb1ae9ca907c3f7acdb Mon Sep 17 00:00:00 2001 From: Mikhail Sokolov Date: Thu, 14 Jun 2018 13:48:40 +0300 Subject: [PATCH] IDEA-193321 non-project items checkbox loses its state on switch --- .../ActionSearchEverywhereContributor.java | 3 ++- .../searcheverywhere/SearchEverywhereUI.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/ActionSearchEverywhereContributor.java b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/ActionSearchEverywhereContributor.java index f93c28e42613..5fc16a019b35 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/ActionSearchEverywhereContributor.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/ActionSearchEverywhereContributor.java @@ -61,11 +61,12 @@ public class ActionSearchEverywhereContributor implements SearchEverywhereContri ContributorSearchResult.Builder builder = ContributorSearchResult.builder(); myProvider.filterElements(pattern, element -> { + if (progressIndicator.isCanceled()) return false; + if (!everywhere && element.value instanceof GotoActionModel.ActionWrapper && !((GotoActionModel.ActionWrapper) element.value).isAvailable()) { return true; } - if (progressIndicator.isCanceled()) return false; if (element == null) { LOG.error("Null action has been returned from model"); return true; diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java index 5896e948a59d..9d170bc60f89 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java @@ -91,6 +91,7 @@ public class SearchEverywhereUI extends BorderLayoutPanel implements Disposable, private int myCalcThreadRestartRequestId = 0; private final Object myWorkerRestartRequestLock = new Object(); private final Alarm listOperationsAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, ApplicationManager.getApplication()); + private final Alarm emptyListAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, ApplicationManager.getApplication()); private Runnable searchFinishedHandler = () -> {}; @@ -617,15 +618,13 @@ public class SearchEverywhereUI extends BorderLayoutPanel implements Disposable, } private void handleEmptyResults() { - ApplicationManager.getApplication().invokeLater(() -> { - if (!nonProjectCheckBoxLocked && !isUseNonProjectItems() && !getSearchPattern().isEmpty()) { - setUseNonProjectItems(true); - return; - } - - hideHint(); - }); + assert EventQueue.isDispatchThread() : "Must be EDT"; + if (!nonProjectCheckBoxLocked && !isUseNonProjectItems() && !getSearchPattern().isEmpty()) { + setUseNonProjectItems(true); + return; + } + hideHint(); } @SuppressWarnings("Duplicates") //todo remove suppress #UX-1 @@ -670,6 +669,7 @@ public class SearchEverywhereUI extends BorderLayoutPanel implements Disposable, private void resetList() { listOperationsAlarm.cancelAllRequests(); + emptyListAlarm.cancelAllRequests(); listOperationsAlarm.addRequest(() -> { Dimension oldSize = getPreferredSize(); myResultsList.getEmptyText().setText(IdeBundle.message("label.choosebyname.searching")); @@ -692,7 +692,7 @@ public class SearchEverywhereUI extends BorderLayoutPanel implements Disposable, } if (!anyFound) { - handleEmptyResults(); + emptyListAlarm.addRequest(() -> handleEmptyResults(), 50); } } @@ -728,7 +728,7 @@ public class SearchEverywhereUI extends BorderLayoutPanel implements Disposable, ScrollingUtil.ensureSelectionExists(myResultsList); } firePropertyChange("preferredSize", oldSize, getPreferredSize()); - }, 0); + }, 50); return found; }