-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Microsoft PowerToys version
0.98.0
Installation method
Microsoft Store
Area(s) with issue?
Command Palette
Steps to reproduce
Disable most extensions, leaving only one or two commands.
✔️ Expected Behavior
Display the results returned by the extension.
❌ Actual Behavior
Error(s) on page:
============================================================
😢 An unexpected error occurred in the application.
Summary:
Message: Non-negative number required. (Parameter 'capacity')
Type: System.ArgumentOutOfRangeException
Source: <unknown>
Time: 2026-03-18 15:29:00.4763082
HRESULT: 0x80131502 (-2146233086)
Stack Trace:
at System.Collections.Generic.List`1..ctor(Int32) + 0x66
at Microsoft.CmdPal.UI.ViewModels.MainPage.MainListPage.UpdateSearchTextCore(String, String, Boolean) + 0x3e5
at Microsoft.CmdPal.UI.ViewModels.ListViewModel.<>c__DisplayClass71_0.<OnSearchTextBoxUpdated>b__0() + 0x71
------------------ Full Exception Details ------------------
System.ArgumentOutOfRangeException: Non-negative number required. (Parameter 'capacity')
at System.Collections.Generic.List`1..ctor(Int32) + 0x66
at Microsoft.CmdPal.UI.ViewModels.MainPage.MainListPage.UpdateSearchTextCore(String, String, Boolean) + 0x3e5
at Microsoft.CmdPal.UI.ViewModels.ListViewModel.<>c__DisplayClass71_0.<OnSearchTextBoxUpdated>b__0() + 0x71
ℹ️ If you need further assistance, please include this information in your support request.
ℹ️ Before sending, take a quick look to make sure it doesn't contain any personal or sensitive information.
============================================================
Additional Information
It appears that in ProviderSettings, the values of FallbackCommands with IncludeInGlobalResults set to true are still being counted toward the global fallback total even for providers that have been disabled. This causes the global fallback count to exceed the actual number of commands, which in turn makes the capacity negative in the code below and leads to a crash:
PowerToys/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs
Line 369 in 549b32e
| var commonFallbacks = new List<TopLevelViewModel>(commands.Count - globalFallbacks.Length); |
Perhaps we should filter out disabled items when calculating globalFallbacks.
PowerToys/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs
Lines 127 to 144 in 549b32e
| public string[] GetGlobalFallbacks() | |
| { | |
| var globalFallbacks = new HashSet<string>(); | |
| foreach (var provider in ProviderSettings.Values) | |
| { | |
| foreach (var fallback in provider.FallbackCommands) | |
| { | |
| var fallbackSetting = fallback.Value; | |
| if (fallbackSetting.IsEnabled && fallbackSetting.IncludeInGlobalResults) | |
| { | |
| globalFallbacks.Add(fallback.Key); | |
| } | |
| } | |
| } | |
| return globalFallbacks.ToArray(); | |
| } |