From 995cf568ff58595094ebc450a1fff402266aeefd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 30 May 2021 19:28:18 +1000 Subject: [PATCH] option to allow action keywords to be disabled --- .../Languages/en.xaml | 1 + .../Search/SearchManager.cs | 17 ++++--- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 12 +++++ .../Views/ActionKeywordSetting.xaml | 6 ++- .../Views/ActionKeywordSetting.xaml.cs | 47 +++++++++++++++++++ .../Views/ExplorerSettings.xaml.cs | 33 +++++++++---- 6 files changed, 97 insertions(+), 19 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index a118e7ad0..71b16f159 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -23,6 +23,7 @@ Path Explore Activation: File Content Search: Index Only Search: + (Disabled) Explorer diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 7a79fbb3a..e62fc822c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -46,12 +46,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search var result = new HashSet(PathEqualityComparator.Instance); - if (ActionKeywordMatch(query, settings.PathSearchActionKeyword) || ActionKeywordMatch(query, settings.SearchActionKeyword)) + if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) || ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) { result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false)); } - if ((ActionKeywordMatch(query, settings.IndexOnlySearchActionKeyword) || ActionKeywordMatch(query, settings.SearchActionKeyword)) && + if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexOnlySearchActionKeyword) || ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) && querySearch.Length > 0 && !querySearch.IsLocationPathString()) { @@ -61,18 +61,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search return result.ToList(); } - private bool ActionKeywordMatch(Query query, string allowedActionKeyword) + private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword) { if (query.ActionKeyword == settings.IndexOnlySearchActionKeyword) - return settings.IndexOnlySearchActionKeyword == allowedActionKeyword; + return Settings.ActionKeyword.IndexOnlySearchActionKeyword == allowedActionKeyword && settings.EnabledIndexOnlySearchKeyword; if (query.ActionKeyword == settings.PathSearchActionKeyword) - return settings.PathSearchActionKeyword == allowedActionKeyword; + return Settings.ActionKeyword.PathSearchActionKeyword == allowedActionKeyword && settings.EnabledPathSearchKeyword; if (query.ActionKeyword == settings.SearchActionKeyword) - return settings.SearchActionKeyword == allowedActionKeyword; + return Settings.ActionKeyword.SearchActionKeyword == allowedActionKeyword; - return Query.GlobalPluginWildcardSign == allowedActionKeyword; + + return (Settings.ActionKeyword.IndexOnlySearchActionKeyword == allowedActionKeyword && settings.EnabledIndexOnlySearchKeyword) + || (Settings.ActionKeyword.PathSearchActionKeyword == allowedActionKeyword && settings.EnabledPathSearchKeyword) + || settings.SearchActionKeyword == Query.GlobalPluginWildcardSign; } public async Task> PathSearchAsync(Query query, CancellationToken token = default) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 99bc1bd8c..aaf4d2977 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -23,6 +23,18 @@ namespace Flow.Launcher.Plugin.Explorer public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; + public bool EnabledPathSearchKeyword { get; set; } + public string IndexOnlySearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; + + public bool EnabledIndexOnlySearchKeyword { get; set; } + + internal enum ActionKeyword + { + SearchActionKeyword, + PathSearchActionKeyword, + FileContentSearchActionKeyword, + IndexOnlySearchActionKeyword + } } } \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml index 0e1c7e872..b49ae3465 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml @@ -16,6 +16,7 @@ + @@ -23,8 +24,9 @@ Margin="10" Grid.Row="0" Width="105" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" /> - - + +