@@ -21,8 +21,8 @@ public static class PluginManager
21
21
private static IEnumerable < PluginPair > _contextMenuPlugins ;
22
22
23
23
public static List < PluginPair > AllPlugins { get ; private set ; }
24
- public static readonly List < PluginPair > GlobalPlugins = new List < PluginPair > ( ) ;
25
- public static readonly Dictionary < string , PluginPair > NonGlobalPlugins = new Dictionary < string , PluginPair > ( ) ;
24
+ public static readonly HashSet < PluginPair > GlobalPlugins = new ( ) ;
25
+ public static readonly Dictionary < string , PluginPair > NonGlobalPlugins = new ( ) ;
26
26
27
27
public static IPublicAPI API { private set ; get ; }
28
28
@@ -118,7 +118,9 @@ public static async Task InitializePlugins(IPublicAPI api)
118
118
_contextMenuPlugins = GetPluginsForInterface < IContextMenu > ( ) ;
119
119
foreach ( var plugin in AllPlugins )
120
120
{
121
- foreach ( var actionKeyword in plugin . Metadata . ActionKeywords )
121
+ // set distinct on each plugin's action keywords helps only firing global(*) and action keywords once where a plugin
122
+ // has multiple global and action keywords because we will only add them here once.
123
+ foreach ( var actionKeyword in plugin . Metadata . ActionKeywords . Distinct ( ) )
122
124
{
123
125
switch ( actionKeyword )
124
126
{
@@ -141,7 +143,7 @@ public static async Task InitializePlugins(IPublicAPI api)
141
143
}
142
144
}
143
145
144
- public static List < PluginPair > ValidPluginsForQuery ( Query query )
146
+ public static ICollection < PluginPair > ValidPluginsForQuery ( Query query )
145
147
{
146
148
if ( NonGlobalPlugins . ContainsKey ( query . ActionKeyword ) )
147
149
{
@@ -283,9 +285,7 @@ public static void RemoveActionKeyword(string id, string oldActionkeyword)
283
285
if ( oldActionkeyword == Query . GlobalPluginWildcardSign
284
286
&& // Plugins may have multiple ActionKeywords that are global, eg. WebSearch
285
287
plugin . Metadata . ActionKeywords
286
- . Where ( x => x == Query . GlobalPluginWildcardSign )
287
- . ToList ( )
288
- . Count == 1 )
288
+ . Count ( x => x == Query . GlobalPluginWildcardSign ) == 1 )
289
289
{
290
290
GlobalPlugins . Remove ( plugin ) ;
291
291
}
0 commit comments