@@ -52,21 +52,24 @@ public List<Result> LoadContextMenus(Result result)
52
52
// get all non-system processes whose file path matches that of the given result (processPath)
53
53
var similarProcesses = processHelper . GetSimilarProcesses ( processPath ) ;
54
54
55
- menuOptions . Add ( new Result
55
+ if ( similarProcesses . Count ( ) > 0 )
56
56
{
57
- Title = _context . API . GetTranslation ( "flowlauncher_plugin_processkiller_kill_instances" ) ,
58
- SubTitle = processPath ,
59
- Action = _ =>
57
+ menuOptions . Add ( new Result
60
58
{
61
- foreach ( var p in similarProcesses )
59
+ Title = _context . API . GetTranslation ( "flowlauncher_plugin_processkiller_kill_instances" ) ,
60
+ SubTitle = processPath ,
61
+ Action = _ =>
62
62
{
63
- processHelper . TryKill ( p ) ;
64
- }
63
+ foreach ( var p in similarProcesses )
64
+ {
65
+ processHelper . TryKill ( p ) ;
66
+ }
65
67
66
- return true ;
67
- } ,
68
- IcoPath = processPath
69
- } ) ;
68
+ return true ;
69
+ } ,
70
+ IcoPath = processPath
71
+ } ) ;
72
+ }
70
73
71
74
return menuOptions ;
72
75
}
@@ -86,6 +89,7 @@ private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist,
86
89
SubTitle = path ,
87
90
TitleHighlightData = StringMatcher . FuzzySearch ( termToSearch , p . ProcessName ) . MatchData ,
88
91
Score = pr . Score ,
92
+ ContextData = p . ProcessName ,
89
93
Action = ( c ) =>
90
94
{
91
95
processHelper . TryKill ( p ) ;
@@ -98,14 +102,14 @@ private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist,
98
102
99
103
// When there are multiple results AND all of them are instances of the same executable
100
104
// add a quick option to kill them all at the top of the results.
101
- var firstResult = sortedResults . FirstOrDefault ( ) ? . SubTitle ;
102
- if ( processlist . Count > 1 && ! string . IsNullOrEmpty ( termToSearch ) && sortedResults . All ( r => r . SubTitle == firstResult ) )
105
+ var firstResult = sortedResults . FirstOrDefault ( x => ! string . IsNullOrEmpty ( x . SubTitle ) ) ;
106
+ if ( processlist . Count > 1 && ! string . IsNullOrEmpty ( termToSearch ) && sortedResults . All ( r => r . SubTitle == firstResult ? . SubTitle ) )
103
107
{
104
108
sortedResults . Insert ( 1 , new Result ( )
105
109
{
106
- IcoPath = "Images/app.png" ,
107
- Title = string . Format ( _context . API . GetTranslation ( "flowlauncher_plugin_processkiller_kill_all" ) , termToSearch ) ,
108
- SubTitle = "" ,
110
+ IcoPath = firstResult ? . IcoPath ,
111
+ Title = string . Format ( _context . API . GetTranslation ( "flowlauncher_plugin_processkiller_kill_all" ) , firstResult ? . ContextData ) ,
112
+ SubTitle = string . Format ( _context . API . GetTranslation ( "flowlauncher_plugin_processkiller_kill_all_count" ) , processlist . Count ) ,
109
113
Score = 200 ,
110
114
Action = ( c ) =>
111
115
{
0 commit comments