From 97e62b32533b2a5d3bef793c1623f8d19cc69ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Fri, 10 Oct 2025 17:58:42 +0200 Subject: [PATCH] CmdPal: Update special fallbacks separately from the other fallbacks (#42289) ## Summary of the Pull Request This PR introduces a hotfix that updates special fallback items separately from the rest. This allows the loop handling special fallback items to finish faster, ensuring they are not delayed by other fallback items. As a result, calculator and run fallback items will be more readily available to users. This partially solves #42286 for special fallback items. ## PR Checklist - [ ] Related to: #42286 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../Commands/MainListPage.cs | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs index 4fd4e1ea27..ef7c879d36 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/MainListPage.cs @@ -244,7 +244,36 @@ public partial class MainListPage : DynamicListPage, var commands = _tlcManager.TopLevelCommands; lock (commands) { - UpdateFallbacks(SearchText, commands.ToImmutableArray(), token); + if (token.IsCancellationRequested) + { + return; + } + + // prefilter fallbacks + var specialFallbacks = new List(_specialFallbacks.Length); + var commonFallbacks = new List(); + + foreach (var s in commands) + { + if (!s.IsFallback) + { + continue; + } + + if (_specialFallbacks.Contains(s.CommandProviderId)) + { + specialFallbacks.Add(s); + } + else + { + commonFallbacks.Add(s); + } + } + + // start update of fallbacks; update special fallbacks separately, + // so they can finish faster + UpdateFallbacks(SearchText, specialFallbacks, token); + UpdateFallbacks(SearchText, commonFallbacks, token); if (token.IsCancellationRequested) { @@ -316,15 +345,12 @@ public partial class MainListPage : DynamicListPage, // with a list of all our commands & apps. if (!newFilteredItems.Any() && !newApps.Any()) { - // We're going to start over with our fallbacks - newFallbacks = Enumerable.Empty(); - newFilteredItems = commands.Where(s => !s.IsFallback); // Fallbacks are always included in the list, even if they // don't match the search text. But we don't want to // consider them when filtering the list. - newFallbacks = commands.Where(s => s.IsFallback && !_specialFallbacks.Contains(s.CommandProviderId)); + newFallbacks = commonFallbacks; if (token.IsCancellationRequested) {