From 44d8666e271939737c5abe8bebc70ab7119a333b Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 17:48:57 +1000 Subject: [PATCH 1/7] add warning for Windows Search service not turned on --- .../Languages/en.xaml | 2 + .../Search/SearchManager.cs | 18 ++++---- .../Search/WindowsIndex/IndexSearch.cs | 43 +++++++++++++++---- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index a989327be..031cb108b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -10,6 +10,8 @@ Deletion successful Successfully deleted the {0} Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword + The required service for Windows Index Search does not appear to be running + To fix this, start the Windows Search service. Select here to remove this warning Delete diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 2aa389f89..c7b1b6180 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -12,13 +12,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search { public class SearchManager { - private readonly PluginInitContext context; + internal static PluginInitContext Context; private readonly Settings settings; public SearchManager(Settings settings, PluginInitContext context) { - this.context = context; + Context = context; this.settings = settings; } @@ -99,7 +99,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); if (isEnvironmentVariable) - return EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, context); + return EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, Context); // Query is a location path with a full environment variable, eg. %appdata%\somefolder\ var isEnvironmentVariablePath = querySearch[1..].Contains("%\\"); @@ -141,8 +141,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search if (string.IsNullOrEmpty(querySearchString)) return new List(); - return await IndexSearch.WindowsIndexSearchAsync(querySearchString, - queryConstructor.CreateQueryHelper().ConnectionString, + return await IndexSearch.WindowsIndexSearchAsync( + querySearchString, + queryConstructor.CreateQueryHelper, queryConstructor.QueryForFileContentSearch, settings.IndexSearchExcludedSubdirectoryPaths, query, @@ -178,8 +179,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search { var queryConstructor = new QueryConstructor(settings); - return await IndexSearch.WindowsIndexSearchAsync(querySearchString, - queryConstructor.CreateQueryHelper().ConnectionString, + return await IndexSearch.WindowsIndexSearchAsync( + querySearchString, + queryConstructor.CreateQueryHelper, queryConstructor.QueryForAllFilesAndFolders, settings.IndexSearchExcludedSubdirectoryPaths, query, @@ -192,7 +194,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search var queryConstructor = new QueryConstructor(settings); return await IndexSearch.WindowsIndexSearchAsync(path, - queryConstructor.CreateQueryHelper().ConnectionString, + queryConstructor.CreateQueryHelper, queryConstructor.QueryForTopLevelDirectorySearch, settings.IndexSearchExcludedSubdirectoryPaths, query, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index cfb564924..c22b489e2 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -1,10 +1,9 @@ -using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Microsoft.Search.Interop; using System; using System.Collections.Generic; using System.Data.OleDb; -using System.Linq; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -84,7 +83,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex return results; } - internal async static Task> WindowsIndexSearchAsync(string searchString, string connectionString, + internal async static Task> WindowsIndexSearchAsync(string searchString, + Func queryHelper, Func constructQuery, List exclusionList, Query query, @@ -94,12 +94,29 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex if (regexMatch.Success) return new List(); + + try + { + var constructedQuery = constructQuery(searchString); - var constructedQuery = constructQuery(searchString); - return RemoveResultsInExclusionList( - await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token).ConfigureAwait(false), + return RemoveResultsInExclusionList( + await ExecuteWindowsIndexSearchAsync(constructedQuery, queryHelper().ConnectionString, query, token).ConfigureAwait(false), exclusionList, token); + } + catch (COMException) + { + // Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin + return new List + { + new Result + { + Title = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), + SubTitle = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceFix"), + IcoPath = Constants.ExplorerIconImagePath + } + }; + } } private static List RemoveResultsInExclusionList(List results, List exclusionList, CancellationToken token) @@ -137,9 +154,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex internal static bool PathIsIndexed(string path) { - var csm = new CSearchManager(); - var indexManager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager(); - return indexManager.IncludedInCrawlScope(path) > 0; + try + { + var csm = new CSearchManager(); + var indexManager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager(); + return indexManager.IncludedInCrawlScope(path) > 0; + } + catch(COMException) + { + // Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin + return false; + } } private static void LogException(string message, Exception e) From 86fe66440423b9afbefe2a43e5a04524028696e6 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 19:58:21 +1000 Subject: [PATCH 2/7] add option to remove warning msg and install Everything plugin --- .../Languages/en.xaml | 2 + .../Search/SearchManager.cs | 40 +++++++++---------- .../Search/WindowsIndex/IndexSearch.cs | 37 ++++++++++++++++- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 4 +- 4 files changed, 60 insertions(+), 23 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 031cb108b..b23931fcf 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -12,6 +12,8 @@ Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword The required service for Windows Index Search does not appear to be running To fix this, start the Windows Search service. Select here to remove this warning + The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return + Explorer Alternative Delete diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index c7b1b6180..d86007e74 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -14,12 +14,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search { internal static PluginInitContext Context; - private readonly Settings settings; + internal static Settings Settings; public SearchManager(Settings settings, PluginInitContext context) { Context = context; - this.settings = settings; + Settings = settings; } private class PathEqualityComparator : IEqualityComparer @@ -71,14 +71,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search return allowedActionKeyword switch { - Settings.ActionKeyword.SearchActionKeyword => settings.SearchActionKeywordEnabled && - keyword == settings.SearchActionKeyword, - Settings.ActionKeyword.PathSearchActionKeyword => settings.PathSearchKeywordEnabled && - keyword == settings.PathSearchActionKeyword, + Settings.ActionKeyword.SearchActionKeyword => Settings.SearchActionKeywordEnabled && + keyword == Settings.SearchActionKeyword, + Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled && + keyword == Settings.PathSearchActionKeyword, Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == - settings.FileContentSearchActionKeyword, - Settings.ActionKeyword.IndexSearchActionKeyword => settings.IndexOnlySearchKeywordEnabled && - keyword == settings.IndexSearchActionKeyword + Settings.FileContentSearchActionKeyword, + Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled && + keyword == Settings.IndexSearchActionKeyword }; } @@ -88,11 +88,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search // This allows the user to type the assigned action keyword and only see the list of quick folder links if (string.IsNullOrEmpty(query.Search)) - return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks); + return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks); var results = new HashSet(PathEqualityComparator.Instance); - var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks); + var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks); results.UnionWith(quickaccessLinks); @@ -136,7 +136,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search private async Task> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token) { - var queryConstructor = new QueryConstructor(settings); + var queryConstructor = new QueryConstructor(Settings); if (string.IsNullOrEmpty(querySearchString)) return new List(); @@ -145,14 +145,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search querySearchString, queryConstructor.CreateQueryHelper, queryConstructor.QueryForFileContentSearch, - settings.IndexSearchExcludedSubdirectoryPaths, + Settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } public bool IsFileContentSearch(string actionKeyword) { - return actionKeyword == settings.FileContentSearchActionKeyword; + return actionKeyword == Settings.FileContentSearchActionKeyword; } private List DirectoryInfoClassSearch(Query query, string querySearch, CancellationToken token) @@ -177,13 +177,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search private async Task> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString, CancellationToken token) { - var queryConstructor = new QueryConstructor(settings); + var queryConstructor = new QueryConstructor(Settings); return await IndexSearch.WindowsIndexSearchAsync( querySearchString, queryConstructor.CreateQueryHelper, queryConstructor.QueryForAllFilesAndFolders, - settings.IndexSearchExcludedSubdirectoryPaths, + Settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } @@ -191,12 +191,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search private async Task> WindowsIndexTopLevelFolderSearchAsync(Query query, string path, CancellationToken token) { - var queryConstructor = new QueryConstructor(settings); + var queryConstructor = new QueryConstructor(Settings); return await IndexSearch.WindowsIndexSearchAsync(path, queryConstructor.CreateQueryHelper, queryConstructor.QueryForTopLevelDirectorySearch, - settings.IndexSearchExcludedSubdirectoryPaths, + Settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } @@ -205,10 +205,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search { var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath); - if (!settings.UseWindowsIndexForDirectorySearch) + if (!Settings.UseWindowsIndexForDirectorySearch) return false; - if (settings.IndexSearchExcludedSubdirectoryPaths + if (Settings.IndexSearchExcludedSubdirectoryPaths .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory) .StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))) return false; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index c22b489e2..7890209db 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -3,10 +3,12 @@ using Microsoft.Search.Interop; using System; using System.Collections.Generic; using System.Data.OleDb; +using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using System.Windows; namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex { @@ -107,12 +109,43 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex catch (COMException) { // Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin + if (!SearchManager.Settings.WarnWindowsSearchServiceOff) + return new List(); + + var api = SearchManager.Context.API; + return new List { new Result { - Title = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), - SubTitle = SearchManager.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceFix"), + Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), + SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"), + Action = c => + { + SearchManager.Settings.WarnWindowsSearchServiceOff = false; + + if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine), + api.GetTranslation("plugin_explorer_alternative_title"), + MessageBoxButton.YesNo) == MessageBoxResult.Yes) + { + var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); + + api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0])); + } + else + { + // Clears the warning message because same query string will not alter the displayed result list + api.ChangeQuery(string.Empty); + + api.ChangeQuery(query.RawQuery); + } + + var mainWindow = Application.Current.MainWindow; + mainWindow.Visibility = Visibility.Visible; + mainWindow.Focus(); + + return false; + }, IcoPath = Constants.ExplorerIconImagePath } }; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 13f938dea..88656a401 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin.Explorer.Search; +using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption; using System; @@ -33,6 +33,8 @@ namespace Flow.Launcher.Plugin.Explorer public bool IndexOnlySearchKeywordEnabled { get; set; } + public bool WarnWindowsSearchServiceOff { get; set; } = true; + internal enum ActionKeyword { SearchActionKeyword, From 8df4bb2e8d84b3fd447764f25a82c9094d1d1d32 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 20:12:15 +1000 Subject: [PATCH 3/7] version bump for Explorer plugin --- Plugins/Flow.Launcher.Plugin.Explorer/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 5bd49949f..364674286 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -9,7 +9,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.8.0", + "Version": "1.8.1", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", From 10a30f4abe1ec29861add5e921cd0948844668e3 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 20:16:30 +1000 Subject: [PATCH 4/7] move exception result into its own method --- .../Search/WindowsIndex/IndexSearch.cs | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 7890209db..19c2b24d6 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -112,43 +112,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex if (!SearchManager.Settings.WarnWindowsSearchServiceOff) return new List(); - var api = SearchManager.Context.API; - - return new List - { - new Result - { - Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), - SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"), - Action = c => - { - SearchManager.Settings.WarnWindowsSearchServiceOff = false; - - if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine), - api.GetTranslation("plugin_explorer_alternative_title"), - MessageBoxButton.YesNo) == MessageBoxResult.Yes) - { - var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); - - api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0])); - } - else - { - // Clears the warning message because same query string will not alter the displayed result list - api.ChangeQuery(string.Empty); - - api.ChangeQuery(query.RawQuery); - } - - var mainWindow = Application.Current.MainWindow; - mainWindow.Visibility = Visibility.Visible; - mainWindow.Focus(); - - return false; - }, - IcoPath = Constants.ExplorerIconImagePath - } - }; + return ResultForWindexSearchOff(query.RawQuery); } } @@ -200,6 +164,47 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex } } + private static List ResultForWindexSearchOff(string rawQuery) + { + var api = SearchManager.Context.API; + + return new List + { + new Result + { + Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), + SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"), + Action = c => + { + SearchManager.Settings.WarnWindowsSearchServiceOff = false; + + if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine), + api.GetTranslation("plugin_explorer_alternative_title"), + MessageBoxButton.YesNo) == MessageBoxResult.Yes) + { + var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); + + api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0])); + } + else + { + // Clears the warning message because same query string will not alter the displayed result list + api.ChangeQuery(string.Empty); + + api.ChangeQuery(rawQuery); + } + + var mainWindow = Application.Current.MainWindow; + mainWindow.Visibility = Visibility.Visible; + mainWindow.Focus(); + + return false; + }, + IcoPath = Constants.ExplorerIconImagePath + } + }; + } + private static void LogException(string message, Exception e) { #if DEBUG // Please investigate and handle error from index search From 0f9fd943122dabe39ca0a847682465154406d389 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 20:42:26 +1000 Subject: [PATCH 5/7] handle future scenario where PluginsManager's action keyword increased --- .../Search/WindowsIndex/IndexSearch.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 19c2b24d6..15251fcfb 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -1,3 +1,4 @@ +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Microsoft.Search.Interop; using System; @@ -178,12 +179,20 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex { SearchManager.Settings.WarnWindowsSearchServiceOff = false; + var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); + + var actionKeywordCount = pluginsManagerPlugins.Metadata.ActionKeywords.Count; + + if (actionKeywordCount > 1) + LogException("PluginsManager's action keyword has increased to more than 1, this does not allow for determining the " + + "right action keyword. Explorer's code for managing Windows Search service not running exception needs to be updated", + new InvalidOperationException()); + if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine), api.GetTranslation("plugin_explorer_alternative_title"), - MessageBoxButton.YesNo) == MessageBoxResult.Yes) + MessageBoxButton.YesNo) == MessageBoxResult.Yes + && actionKeywordCount == 1) { - var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); - api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0])); } else From f588f2a763caaca4f6b7fe9774084b4ae40489d2 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 25 Jul 2021 20:44:04 +1000 Subject: [PATCH 6/7] fix typo --- .../Search/WindowsIndex/IndexSearch.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 15251fcfb..d42989457 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -179,9 +179,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex { SearchManager.Settings.WarnWindowsSearchServiceOff = false; - var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); + var pluginsManagerPlugin= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); - var actionKeywordCount = pluginsManagerPlugins.Metadata.ActionKeywords.Count; + var actionKeywordCount = pluginsManagerPlugin.Metadata.ActionKeywords.Count; if (actionKeywordCount > 1) LogException("PluginsManager's action keyword has increased to more than 1, this does not allow for determining the " + @@ -193,7 +193,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex MessageBoxButton.YesNo) == MessageBoxResult.Yes && actionKeywordCount == 1) { - api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0])); + api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugin.Metadata.ActionKeywords[0])); } else { From bd15aa7ef912f7ded36d4fecd85e25d775e1145b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 27 Jul 2021 18:55:52 +1000 Subject: [PATCH 7/7] pass query helper object --- .../Search/SearchManager.cs | 9 +++++---- .../Search/WindowsIndex/IndexSearch.cs | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index d86007e74..9995f45d3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -143,7 +143,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return await IndexSearch.WindowsIndexSearchAsync( querySearchString, - queryConstructor.CreateQueryHelper, + queryConstructor.CreateQueryHelper(), queryConstructor.QueryForFileContentSearch, Settings.IndexSearchExcludedSubdirectoryPaths, query, @@ -181,7 +181,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return await IndexSearch.WindowsIndexSearchAsync( querySearchString, - queryConstructor.CreateQueryHelper, + queryConstructor.CreateQueryHelper(), queryConstructor.QueryForAllFilesAndFolders, Settings.IndexSearchExcludedSubdirectoryPaths, query, @@ -193,8 +193,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search { var queryConstructor = new QueryConstructor(Settings); - return await IndexSearch.WindowsIndexSearchAsync(path, - queryConstructor.CreateQueryHelper, + return await IndexSearch.WindowsIndexSearchAsync( + path, + queryConstructor.CreateQueryHelper(), queryConstructor.QueryForTopLevelDirectorySearch, Settings.IndexSearchExcludedSubdirectoryPaths, query, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index d42989457..010a19b58 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -86,12 +86,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex return results; } - internal async static Task> WindowsIndexSearchAsync(string searchString, - Func queryHelper, - Func constructQuery, - List exclusionList, - Query query, - CancellationToken token) + internal async static Task> WindowsIndexSearchAsync( + string searchString, + CSearchQueryHelper queryHelper, + Func constructQuery, + List exclusionList, + Query query, + CancellationToken token) { var regexMatch = Regex.Match(searchString, reservedStringPattern); @@ -103,7 +104,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex var constructedQuery = constructQuery(searchString); return RemoveResultsInExclusionList( - await ExecuteWindowsIndexSearchAsync(constructedQuery, queryHelper().ConnectionString, query, token).ConfigureAwait(false), + await ExecuteWindowsIndexSearchAsync(constructedQuery, queryHelper.ConnectionString, query, token).ConfigureAwait(false), exclusionList, token); }