Merge pull request #164 from Flow-Launcher/sort_plugin_processkiller_results

Sort plugin ProcessKiller's results ascending
This commit is contained in:
Jeremy Wu 2020-09-28 15:32:55 +10:00 committed by GitHub
commit e204a092ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -94,12 +94,14 @@ namespace Flow.Launcher.Plugin.ProcessKiller
});
}
var sortedResults = results.OrderBy(x => x.Title).ToList();
// When there are multiple results AND all of them are instances of the same executable
// add a quick option to kill them all at the top of the results.
var firstResult = results.FirstOrDefault()?.SubTitle;
if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && results.All(r => r.SubTitle == firstResult))
var firstResult = sortedResults.FirstOrDefault()?.SubTitle;
if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult))
{
results.Insert(0, new Result()
sortedResults.Insert(1, new Result()
{
IcoPath = "Images/app.png",
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch),
@ -117,7 +119,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
});
}
return results;
return sortedResults;
}
}
}

View file

@ -4,7 +4,7 @@
"Name":"Process Killer",
"Description":"kill running processes from Flow",
"Author":"Flow-Launcher",
"Version":"1.0.0",
"Version":"1.1.0",
"Language":"csharp",
"Website":"https://github.com/Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller",
"IcoPath":"Images\\app.png",