CmdPal: Filtering out pinned apps on search (#40785)

Closes #40781 

Filters out TopLevelCommands whose Id matches an app coming from the
`AllAppsCommandProvider.Page.GetItems()`.

Hate adding processing there, but without adding some type of `bool
HideMeOnSearch` to something low enough (like ICommandItem), I don't see
another way to distinguish these.
This commit is contained in:
Michael Jolley
2025-07-28 08:45:08 -05:00
committed by GitHub
parent 858081ec78
commit 114c3972be
3 changed files with 8 additions and 7 deletions

View File

@@ -164,6 +164,11 @@ public partial class MainListPage : DynamicListPage,
if (_includeApps)
{
IEnumerable<IListItem> apps = AllAppsCommandProvider.Page.GetItems();
var appIds = apps.Select(app => app.Command.Id).ToArray();
// Remove any top level pinned apps and use the apps from AllAppsCommandProvider.Page.GetItems()
// since they contain details.
_filteredItems = _filteredItems.Where(item => item.Command is not AppCommand);
_filteredItems = _filteredItems.Concat(apps);
}
}

View File

@@ -6,11 +6,9 @@ using System;
using System.Diagnostics;
using System.Threading.Tasks;
using ManagedCommon;
using Microsoft.CmdPal.Ext.Apps.Programs;
using Microsoft.CmdPal.Ext.Apps.Properties;
using Microsoft.CmdPal.Ext.Apps.Utils;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.Services.Maps;
using Windows.Win32;
using Windows.Win32.System.Com;
using Windows.Win32.UI.Shell;
@@ -18,11 +16,11 @@ using WyHash;
namespace Microsoft.CmdPal.Ext.Apps;
internal sealed partial class AppCommand : InvokableCommand
public sealed partial class AppCommand : InvokableCommand
{
private readonly AppItem _app;
internal AppCommand(AppItem app)
public AppCommand(AppItem app)
{
_app = app;

View File

@@ -3,13 +3,11 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using Microsoft.CmdPal.Ext.Apps.Programs;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Apps;
internal sealed class AppItem
public sealed class AppItem
{
public string Name { get; set; } = string.Empty;