Use Constant Name

This commit is contained in:
Kevin Zhang 2021-07-03 00:20:33 +08:00
parent e8a9377ec4
commit 192d64bb2a
3 changed files with 7 additions and 7 deletions

View file

@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Action = c => Action = c =>
{ {
if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnableSearchActionKeyword)) if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnabledSearchActionKeyword))
{ {
try try
{ {
@ -42,9 +42,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
} }
// one of it is enabled // one of it is enabled
var keyword = Settings.EnableSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; var keyword = Settings.EnabledSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
keyword = keyword == "*" ? "" : $"{keyword} "; keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + "";
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
Context.API.ChangeQuery($"{keyword}{changeTo}"); Context.API.ChangeQuery($"{keyword}{changeTo}");

View file

@ -71,7 +71,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return allowedActionKeyword switch return allowedActionKeyword switch
{ {
Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword && Settings.ActionKeyword.SearchActionKeyword => settings.EnabledSearchActionKeyword &&
keyword == settings.SearchActionKeyword, keyword == settings.SearchActionKeyword,
Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword && Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword &&
keyword == settings.PathSearchActionKeyword, keyword == settings.PathSearchActionKeyword,

View file

@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>(); public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnableSearchActionKeyword { get; set; } = true; public bool EnabledSearchActionKeyword { get; set; } = true;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
@ -60,7 +60,7 @@ namespace Flow.Launcher.Plugin.Explorer
internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
{ {
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword, ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword,
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword, ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword, ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword,
_ => null _ => null
@ -68,7 +68,7 @@ namespace Flow.Launcher.Plugin.Explorer
internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
{ {
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable, ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword = enable,
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable, ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable, ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")