From cae2dd0e68d6e55ef810166ecdd691a27705fa2b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 21 Jul 2015 15:18:52 +0200 Subject: [PATCH] Search Everywhere: start searching symbols and files in global scope if nothing's found --- .../ide/actions/SearchEverywhereAction.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 6f968e381b58..516c309e9fa6 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -1518,7 +1518,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } private synchronized void buildFiles(final String pattern) { - final SearchResult files = getFiles(pattern, MAX_FILES, myFileChooseByName); + final SearchResult files = getFiles(pattern, showAll.get(), MAX_FILES, myFileChooseByName); check(); @@ -1704,6 +1704,11 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA return !symbols.needMore; } }); + + if (!includeLibs && symbols.isEmpty()) { + return getSymbols(pattern, max, true, chooseByNamePopup); + } + return symbols; } @@ -1752,7 +1757,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA return classes; } - private SearchResult getFiles(final String pattern, final int max, ChooseByNamePopup chooseByNamePopup) { + private SearchResult getFiles(final String pattern, final boolean includeLibs, final int max, ChooseByNamePopup chooseByNamePopup) { final SearchResult files = new SearchResult(); if (chooseByNamePopup == null || !Registry.is("search.everywhere.files")) { return files; @@ -1772,7 +1777,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } if (file != null && !(pattern.indexOf(' ') != -1 && file.getName().indexOf(' ') == -1) - && (showAll.get() || scope.accept(file) + && (includeLibs || scope.accept(file) && !myListModel.contains(file) && !myAlreadyAddedFiles.contains(file)) && !files.contains(file)) { @@ -1785,6 +1790,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA return true; } }); + if (!includeLibs && files.isEmpty()) { + return getFiles(pattern, true, max, chooseByNamePopup); + } + return files; } @@ -2145,7 +2154,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA try { final SearchResult result = id == WidgetID.CLASSES ? getClasses(pattern, showAll.get(), DEFAULT_MORE_STEP_COUNT, myClassChooseByName) - : id == WidgetID.FILES ? getFiles(pattern, DEFAULT_MORE_STEP_COUNT, myFileChooseByName) + : id == WidgetID.FILES ? getFiles(pattern, showAll.get(), DEFAULT_MORE_STEP_COUNT, myFileChooseByName) : id == WidgetID.RUN_CONFIGURATIONS ? getConfigurations(pattern, DEFAULT_MORE_STEP_COUNT) : id == WidgetID.SYMBOLS ? getSymbols(pattern, DEFAULT_MORE_STEP_COUNT, showAll.get(), mySymbolsChooseByName) : id == WidgetID.ACTIONS ? getActionsOrSettings(pattern, DEFAULT_MORE_STEP_COUNT, true)