Skip to content

Commit 22dd59e

Browse files
Merge pull request #2170 from JohnTheGr8/kill_honor_last_query_style
plugin/ProcessKiller: honor "Last Query Style" after kill
2 parents bbaa388 + 6bdf6ac commit 22dd59e

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Linq;
33
using Flow.Launcher.Infrastructure;
4-
using System.Threading.Tasks;
54

65
namespace Flow.Launcher.Plugin.ProcessKiller
76
{
@@ -89,7 +88,8 @@ private List<Result> CreateResultsFromQuery(Query query)
8988
Action = (c) =>
9089
{
9190
processHelper.TryKill(p);
92-
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
91+
// Re-query to refresh process list
92+
_context.API.ChangeQuery(query.RawQuery, true);
9393
return true;
9494
}
9595
});
@@ -114,19 +114,14 @@ private List<Result> CreateResultsFromQuery(Query query)
114114
{
115115
processHelper.TryKill(p.Process);
116116
}
117-
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
117+
// Re-query to refresh process list
118+
_context.API.ChangeQuery(query.RawQuery, true);
118119
return true;
119120
}
120121
});
121122
}
122123

123124
return sortedResults;
124125
}
125-
126-
private static async Task DelayAndReQueryAsync(string query)
127-
{
128-
await Task.Delay(500);
129-
_context.API.ChangeQuery(query, true);
130-
}
131126
}
132127
}

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Infrastructure;
1+
using Flow.Launcher.Infrastructure;
22
using Flow.Launcher.Infrastructure.Logger;
33
using System;
44
using System.Collections.Generic;
@@ -75,6 +75,7 @@ public void TryKill(Process p)
7575
if (!p.HasExited)
7676
{
7777
p.Kill();
78+
p.WaitForExit(50);
7879
}
7980
}
8081
catch (Exception e)

0 commit comments

Comments
 (0)