Add the SearchMaxResults const

This commit is contained in:
Namhyeon Go 2025-05-24 16:09:33 +09:00
parent 9b64204771
commit c9b6c6a117

View File

@ -19,6 +19,7 @@ namespace WelsonJS.Launcher.ResourceTools
private readonly HttpClient _httpClient;
private const string Prefix = "completion/";
private readonly ConcurrentBag<string> DiscoveredExecutables = new ConcurrentBag<string>();
private const int SearchMaxResults = 200;
public Completion(ResourceServer server, HttpClient httpClient)
{
@ -45,7 +46,7 @@ namespace WelsonJS.Launcher.ResourceTools
{
List<CompletionItem> completionItems = DiscoveredExecutables.ToList()
.Where(exec => exec.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) > -1)
.Take(100) // Limit the number of results
.Take(SearchMaxResults) // Limit the number of results
.Select(exec => new CompletionItem
{
Label = Path.GetFileName(exec),
@ -162,6 +163,7 @@ namespace WelsonJS.Launcher.ResourceTools
try
{
var executableFiles = Directory.GetFiles(path, "*.exe", searchOption)
.Take(SearchMaxResults)
.OrderByDescending(f => new FileInfo(f).Length)
.ToList();