sort ProcessKiller plugin's results ascending

This commit is contained in:
Jeremy Wu 2020-09-24 07:22:55 +10:00
parent ec5f7275de
commit 2d45a79aed

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;
}
}
}