From 21479431173344cf83bd7939410e999a9f986b32 Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Sat, 22 Apr 2023 01:08:10 +0800
Subject: [PATCH 1/2] Fix API docstring format
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index d9cf68469..19b69b015 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -20,8 +20,8 @@ namespace Flow.Launcher.Plugin
///
/// query text
///
- /// force requery By default, Flow Launcher will not fire query if your query is same with existing one.
- /// Set this to true to force Flow Launcher requerying
+ /// Force requery. By default, Flow Launcher will not fire query if your query is same with existing one.
+ /// Set this to to force Flow Launcher requerying
///
void ChangeQuery(string query, bool requery = false);
From 3ae656f456be00a5349738869aa8a1f64568a8c8 Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Mon, 24 Apr 2023 00:45:38 +0800
Subject: [PATCH 2/2] Requery after killing a process
---
.../Main.cs | 38 ++++++++++---------
.../ProcessHelper.cs | 2 +-
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
index 19f96aea1..3eff7e398 100644
--- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
@@ -1,12 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Diagnostics;
-using System.Dynamic;
-using System.Runtime.InteropServices;
using Flow.Launcher.Infrastructure;
-using Flow.Launcher.Infrastructure.Logger;
+using System.Threading.Tasks;
namespace Flow.Launcher.Plugin.ProcessKiller
{
@@ -23,13 +18,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
public List Query(Query query)
{
- var termToSearch = query.Search;
-
- var processlist = processHelper.GetMatchingProcesses(termToSearch);
-
- return !processlist.Any()
- ? null
- : CreateResultsFromProcesses(processlist, termToSearch);
+ return CreateResultsFromQuery(query);
}
public string GetTranslatedPluginTitle()
@@ -50,7 +39,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
// get all non-system processes whose file path matches that of the given result (processPath)
var similarProcesses = processHelper.GetSimilarProcesses(processPath);
- if (similarProcesses.Count() > 0)
+ if (similarProcesses.Any())
{
menuOptions.Add(new Result
{
@@ -72,8 +61,16 @@ namespace Flow.Launcher.Plugin.ProcessKiller
return menuOptions;
}
- private List CreateResultsFromProcesses(List processlist, string termToSearch)
+ private List CreateResultsFromQuery(Query query)
{
+ string termToSearch = query.Search;
+ var processlist = processHelper.GetMatchingProcesses(termToSearch);
+
+ if (!processlist.Any())
+ {
+ return null;
+ }
+
var results = new List();
foreach (var pr in processlist)
@@ -92,6 +89,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
Action = (c) =>
{
processHelper.TryKill(p);
+ _ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
return true;
}
});
@@ -116,7 +114,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
{
processHelper.TryKill(p.Process);
}
-
+ _ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
return true;
}
});
@@ -124,5 +122,11 @@ namespace Flow.Launcher.Plugin.ProcessKiller
return sortedResults;
}
+
+ private static async Task DelayAndReQueryAsync(string query)
+ {
+ await Task.Delay(500);
+ _context.API.ChangeQuery(query, true);
+ }
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
index 16a8687e6..0932955d6 100644
--- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
+++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
@@ -79,7 +79,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
}
catch (Exception e)
{
- Log.Exception($"|ProcessKiller.CreateResultsFromProcesses|Failed to kill process {p.ProcessName}", e);
+ Log.Exception($"{nameof(ProcessHelper)}", $"Failed to kill process {p.ProcessName}", e);
}
}