@@ -342,10 +342,17 @@ public static List<Result> GetContextMenusForPlugin(Result result)
342342
343343 public static bool ActionKeywordRegistered ( IReadOnlyList < string > actionKeywords )
344344 {
345- return actionKeywords . Any ( ActionKeywordRegistered ) ;
345+ foreach ( var actionKeyword in actionKeywords )
346+ {
347+ if ( ActionKeywordRegistered ( actionKeyword ) )
348+ {
349+ return true ;
350+ }
351+ }
352+ return false ;
346353 }
347354
348- private static bool ActionKeywordRegistered ( string actionKeyword )
355+ public static bool ActionKeywordRegistered ( string actionKeyword )
349356 {
350357 // this method is only checking for action keywords (defined as not '*') registration
351358 // hence the actionKeyword != Query.GlobalPluginWildcardSign logic
@@ -369,6 +376,7 @@ public static void AddActionKeyword(string id, string newActionKeyword)
369376 NonGlobalPlugins [ newActionKeyword ] = plugin ;
370377 }
371378
379+ // Update action keywords in plugin metadata
372380 plugin . Metadata . ActionKeywords . Add ( newActionKeyword ) ;
373381 }
374382
@@ -390,27 +398,28 @@ public static void RemoveActionKeyword(string id, string oldActionkeyword)
390398 if ( oldActionkeyword != Query . GlobalPluginWildcardSign )
391399 NonGlobalPlugins . Remove ( oldActionkeyword ) ;
392400
401+ // Update action keywords in plugin metadata
393402 plugin . Metadata . ActionKeywords . Remove ( oldActionkeyword ) ;
394403 }
395404
396- public static void ReplaceActionKeyword ( string id , IReadOnlyList < string > oldActionKeyword , IReadOnlyList < string > newActionKeyword )
405+ public static void ReplaceActionKeyword ( string id , IReadOnlyList < string > oldActionKeywords , IReadOnlyList < string > newActionKeywords )
397406 {
398- if ( CheckActionKeywordChanged ( oldActionKeyword , newActionKeyword ) )
407+ if ( CheckActionKeywordChanged ( oldActionKeywords , newActionKeywords ) )
399408 {
400- foreach ( var actionKeyword in newActionKeyword )
409+ foreach ( var actionKeyword in newActionKeywords )
401410 {
402411 AddActionKeyword ( id , actionKeyword ) ;
403412 }
404- foreach ( var actionKeyword in oldActionKeyword )
413+ foreach ( var actionKeyword in oldActionKeywords )
405414 {
406415 RemoveActionKeyword ( id , actionKeyword ) ;
407416 }
408417
409418 // Update action keyword in plugin metadata
410419 var plugin = GetPluginForId ( id ) ;
411- if ( newActionKeyword . Count > 0 )
420+ if ( newActionKeywords . Count > 0 )
412421 {
413- plugin . Metadata . ActionKeyword = newActionKeyword [ 0 ] ;
422+ plugin . Metadata . ActionKeyword = newActionKeywords [ 0 ] ;
414423 }
415424 else
416425 {
@@ -426,6 +435,27 @@ private static bool CheckActionKeywordChanged(IReadOnlyList<string> oldActionKey
426435 return oldActionKeyword . Where ( ( t , i ) => t != newActionKeyword [ i ] ) . Any ( ) ;
427436 }
428437
438+ public static void ReplaceActionKeyword ( string id , string oldActionKeyword , string newActionKeyword )
439+ {
440+ if ( oldActionKeyword != newActionKeyword )
441+ {
442+ AddActionKeyword ( id , newActionKeyword ) ;
443+ RemoveActionKeyword ( id , oldActionKeyword ) ;
444+
445+ // Update action keyword in plugin metadata
446+ var plugin = GetPluginForId ( id ) ;
447+ var newActionKeywords = plugin . Metadata . ActionKeywords ;
448+ if ( newActionKeywords . Count > 0 )
449+ {
450+ plugin . Metadata . ActionKeyword = newActionKeywords [ 0 ] ;
451+ }
452+ else
453+ {
454+ plugin . Metadata . ActionKeyword = string . Empty ;
455+ }
456+ }
457+ }
458+
429459 private static string GetContainingFolderPathAfterUnzip ( string unzippedParentFolderPath )
430460 {
431461 var unzippedFolderCount = Directory . GetDirectories ( unzippedParentFolderPath ) . Length ;
0 commit comments