mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
CmdPal: Added settings for limiting apps on top level searches (#40915)
Closes #40062 Adds a setting to limit the number of apps returned on top level searches. Can limit to none, 1, 5, 10, or 20. https://github.com/user-attachments/assets/de60111f-fb02-4db6-9ae9-2f636c171b5b
This commit is contained in:
@@ -43,13 +43,18 @@ public partial class ListHelpers
|
||||
}
|
||||
|
||||
public static IEnumerable<T> FilterList<T>(IEnumerable<T> items, string query, Func<string, T, int> scoreFunction)
|
||||
{
|
||||
return FilterListWithScores<T>(items, query, scoreFunction)
|
||||
.Select(score => score.Item);
|
||||
}
|
||||
|
||||
public static IEnumerable<Scored<T>> FilterListWithScores<T>(IEnumerable<T> items, string query, Func<string, T, int> scoreFunction)
|
||||
{
|
||||
var scores = items
|
||||
.Select(li => new Scored<T>() { Item = li, Score = scoreFunction(query, li) })
|
||||
.Where(score => score.Score > 0)
|
||||
.OrderByDescending(score => score.Score);
|
||||
return scores
|
||||
.Select(score => score.Item);
|
||||
return scores;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user