I think this is everything working now

This commit is contained in:
Mike Griese
2026-02-18 10:13:12 -06:00
parent fcf4b0727b
commit 1a4e971092
2 changed files with 21 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ using Microsoft.CmdPal.Core.ViewModels;
namespace Microsoft.CmdPal.UI.ViewModels;
internal partial class TopLevelItemPageContext : IPageContext
public partial class TopLevelItemPageContext : IPageContext
{
public TaskScheduler Scheduler { get; private set; }

View File

@@ -46,16 +46,27 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
var alreadyPinnedToTopLevel = providerSettings.PinnedCommandIds.Contains(itemId);
var pinToTopLevelCommand = new PinToCommand(
commandId: itemId,
providerId: providerId,
pin: !alreadyPinnedToTopLevel,
PinLocation.TopLevel,
_settingsModel,
_topLevelCommandManager);
// Don't add pin/unpin commands for items displayed as
// TopLevelViewModels that aren't already pinned.
//
// We can't look up if this command item is in the top level
// items in the manager, because we are being called _before_ we
// get added to the manager's list of commands.
var isTopLevelItem = page is TopLevelItemPageContext;
var contextItem = new PinToContextItem(pinToTopLevelCommand, commandItem);
moreCommands.Add(contextItem);
if (!isTopLevelItem || alreadyPinnedToTopLevel)
{
var pinToTopLevelCommand = new PinToCommand(
commandId: itemId,
providerId: providerId,
pin: !alreadyPinnedToTopLevel,
PinLocation.TopLevel,
_settingsModel,
_topLevelCommandManager);
var contextItem = new PinToContextItem(pinToTopLevelCommand, commandItem);
moreCommands.Add(contextItem);
}
}
}