Change context and settings to non static

This commit is contained in:
Vic 2023-01-19 14:47:42 +08:00
parent 009ee3dc5c
commit 52e72992c2
3 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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<Result> EverythingContentSearchResult(Query query)
private List<Result> EverythingContentSearchResult(Query query)
{
return new List<Result>()
{
@ -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)

View file

@ -97,10 +97,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
private IAsyncEnumerable<SearchResult> HandledEngineNotAvailableExceptionAsync()
{
if (!SearchManager.Settings.WarnWindowsSearchServiceOff)
if (!Settings.WarnWindowsSearchServiceOff)
return AsyncEnumerable.Empty<SearchResult>();
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);