From 55164ef60ffd9b10bcae9b2c500c4a139f692b83 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 21 Jul 2025 16:29:01 +0800 Subject: [PATCH] Improve code quality --- Flow.Launcher.Core/Plugin/PluginManager.cs | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 5edf43a33..e985be518 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -273,25 +273,12 @@ namespace Flow.Launcher.Core.Plugin // Register ResultsUpdated event so that plugin query can use results updated interface register.RegisterResultsUpdatedEvent(pair); - // Register plugin's action keywords so that plugins can be queried in results - // set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin - // has multiple global and action keywords because we will only add them here once. - foreach (var actionKeyword in pair.Metadata.ActionKeywords.Distinct()) - { - switch (actionKeyword) - { - case Query.GlobalPluginWildcardSign: - _globalPlugins.TryAdd(pair.Metadata.ID, pair); - break; - default: - _nonGlobalPlugins.TryAdd(actionKeyword, pair); - break; - } - } - // Update plugin metadata translation after the plugin is initialized with IPublicAPI instance Internationalization.UpdatePluginMetadataTranslation(pair); + // Register plugin action keywords so that plugins can be queried in results + RegisterPluginActionKeywords(pair); + // Add plugin to Dialog Jump plugin list after the plugin is initialized DialogJump.InitializeDialogJumpPlugin(pair); @@ -316,6 +303,24 @@ namespace Flow.Launcher.Core.Plugin } } + private static void RegisterPluginActionKeywords(PluginPair pair) + { + // set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin + // has multiple global and action keywords because we will only add them here once. + foreach (var actionKeyword in pair.Metadata.ActionKeywords.Distinct()) + { + switch (actionKeyword) + { + case Query.GlobalPluginWildcardSign: + _globalPlugins.TryAdd(pair.Metadata.ID, pair); + break; + default: + _nonGlobalPlugins.TryAdd(actionKeyword, pair); + break; + } + } + } + private static void AddPluginToLists(PluginPair pair) { if (pair.Plugin is IContextMenu)