diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index e4ecf0f40..c8f78767c 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -342,10 +342,17 @@ namespace Flow.Launcher.Core.Plugin public static bool ActionKeywordRegistered(IReadOnlyList actionKeywords) { - return actionKeywords.Any(ActionKeywordRegistered); + foreach (var actionKeyword in actionKeywords) + { + if (ActionKeywordRegistered(actionKeyword)) + { + return true; + } + } + return false; } - private static bool ActionKeywordRegistered(string actionKeyword) + public static bool ActionKeywordRegistered(string actionKeyword) { // this method is only checking for action keywords (defined as not '*') registration // hence the actionKeyword != Query.GlobalPluginWildcardSign logic @@ -369,6 +376,7 @@ namespace Flow.Launcher.Core.Plugin NonGlobalPlugins[newActionKeyword] = plugin; } + // Update action keywords in plugin metadata plugin.Metadata.ActionKeywords.Add(newActionKeyword); } @@ -390,27 +398,28 @@ namespace Flow.Launcher.Core.Plugin if (oldActionkeyword != Query.GlobalPluginWildcardSign) NonGlobalPlugins.Remove(oldActionkeyword); + // Update action keywords in plugin metadata plugin.Metadata.ActionKeywords.Remove(oldActionkeyword); } - public static void ReplaceActionKeyword(string id, IReadOnlyList oldActionKeyword, IReadOnlyList newActionKeyword) + public static void ReplaceActionKeyword(string id, IReadOnlyList oldActionKeywords, IReadOnlyList newActionKeywords) { - if (CheckActionKeywordChanged(oldActionKeyword, newActionKeyword)) + if (CheckActionKeywordChanged(oldActionKeywords, newActionKeywords)) { - foreach (var actionKeyword in newActionKeyword) + foreach (var actionKeyword in newActionKeywords) { AddActionKeyword(id, actionKeyword); } - foreach (var actionKeyword in oldActionKeyword) + foreach (var actionKeyword in oldActionKeywords) { RemoveActionKeyword(id, actionKeyword); } // Update action keyword in plugin metadata var plugin = GetPluginForId(id); - if (newActionKeyword.Count > 0) + if (newActionKeywords.Count > 0) { - plugin.Metadata.ActionKeyword = newActionKeyword[0]; + plugin.Metadata.ActionKeyword = newActionKeywords[0]; } else { @@ -426,6 +435,27 @@ namespace Flow.Launcher.Core.Plugin return oldActionKeyword.Where((t, i) => t != newActionKeyword[i]).Any(); } + public static void ReplaceActionKeyword(string id, string oldActionKeyword, string newActionKeyword) + { + if (oldActionKeyword != newActionKeyword) + { + AddActionKeyword(id, newActionKeyword); + RemoveActionKeyword(id, oldActionKeyword); + + // Update action keyword in plugin metadata + var plugin = GetPluginForId(id); + var newActionKeywords = plugin.Metadata.ActionKeywords; + if (newActionKeywords.Count > 0) + { + plugin.Metadata.ActionKeyword = newActionKeywords[0]; + } + else + { + plugin.Metadata.ActionKeyword = string.Empty; + } + } + } + private static string GetContainingFolderPathAfterUnzip(string unzippedParentFolderPath) { var unzippedFolderCount = Directory.GetDirectories(unzippedParentFolderPath).Length; diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs index a3e5630c2..f79176f99 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs @@ -80,7 +80,7 @@ namespace Flow.Launcher.Plugin.WebSearch private void AddSearchSource() { var keyword = _searchSource.ActionKeyword; - if (!PluginManager.ActionKeywordRegistered(keyword)) + if (!_context.API.ActionKeywordAssigned(keyword)) { var id = _context.CurrentPluginMetadata.ID; PluginManager.AddActionKeyword(id, keyword); @@ -100,7 +100,7 @@ namespace Flow.Launcher.Plugin.WebSearch { var newKeyword = _searchSource.ActionKeyword; var oldKeyword = _oldSearchSource.ActionKeyword; - if (!PluginManager.ActionKeywordRegistered(newKeyword) || oldKeyword == newKeyword) + if (!_context.API.ActionKeywordAssigned(newKeyword) || oldKeyword == newKeyword) { var id = _context.CurrentPluginMetadata.ID; PluginManager.ReplaceActionKeyword(id, oldKeyword, newKeyword);