From 52e72992c2d417e2fd5b3e149a568aa0fef6aabe Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 19 Jan 2023 14:47:42 +0800 Subject: [PATCH] Change context and settings to non static --- Flow.Launcher.Test/Plugins/ExplorerTest.cs | 3 ++- .../Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 8 ++++---- .../Search/WindowsIndex/WindowsIndexSearchManager.cs | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher.Test/Plugins/ExplorerTest.cs b/Flow.Launcher.Test/Plugins/ExplorerTest.cs index 36f0294a9..4075947ff 100644 --- a/Flow.Launcher.Test/Plugins/ExplorerTest.cs +++ b/Flow.Launcher.Test/Plugins/ExplorerTest.cs @@ -176,7 +176,7 @@ namespace Flow.Launcher.Test.Plugins var searchManager = new SearchManager(new Settings(), new PluginInitContext()); // When - var result = SearchManager.IsFileContentSearch(query.ActionKeyword); + var result = searchManager.IsFileContentSearch(query.ActionKeyword); // Then Assert.IsTrue(result, @@ -193,6 +193,7 @@ namespace Flow.Launcher.Test.Plugins [TestCase(@"c:\>*", true)] [TestCase(@"c:\>", true)] [TestCase(@"c:\SomeLocation\SomeOtherLocation\>", true)] + [TestCase(@"c:\SomeLocation\SomeOtherLocation", true)] public void WhenGivenQuerySearchString_ThenShouldIndicateIfIsLocationPathString(string querySearchString, bool expectedResult) { // When, Given diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 677b7f038..ce1283e06 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -13,9 +13,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search { public class SearchManager { - internal static PluginInitContext Context; + internal PluginInitContext Context; - internal static Settings Settings; + internal Settings Settings; public SearchManager(Settings settings, PluginInitContext context) { @@ -144,7 +144,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search }; } - private static List EverythingContentSearchResult(Query query) + private List EverythingContentSearchResult(Query query) { return new List() { @@ -236,7 +236,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return results.ToList(); } - public static bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword; + public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword; private bool UseWindowsIndexForDirectorySearch(string locationPath) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs index abb50849d..f1060a4ac 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs @@ -97,10 +97,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex private IAsyncEnumerable HandledEngineNotAvailableExceptionAsync() { - if (!SearchManager.Settings.WarnWindowsSearchServiceOff) + if (!Settings.WarnWindowsSearchServiceOff) return AsyncEnumerable.Empty(); - var api = SearchManager.Context.API; + var api = Main.Context.API; throw new EngineNotAvailableException( "Windows Index", @@ -108,7 +108,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), c => { - SearchManager.Settings.WarnWindowsSearchServiceOff = false; + Settings.WarnWindowsSearchServiceOff = false; // Clears the warning message so user is not mistaken that it has not worked api.ChangeQuery(string.Empty);