Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Show Shortcut/KeyBinding of Command in Menu #414

Open
joshdavidson613 opened this issue Sep 5, 2024 · 1 comment
Open

Unable to Show Shortcut/KeyBinding of Command in Menu #414

joshdavidson613 opened this issue Sep 5, 2024 · 1 comment
Assignees
Milestone

Comments

@joshdavidson613
Copy link

Hi all, really like what you are trying to do here. Quick question. I was able to get CommandConfiguration object working with KeyBinding/Shortcut:

public override CommandConfiguration CommandConfiguration => new("MyExtension.Command1.DisplayName")
  {
      // Use this object initializer to set optional parameters for the command. The required parameter,
      // displayName, is set above. DisplayName is localized and references an entry in .vsextension\string-resources.json.
      //Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu],
      Icon = new (ImageMoniker.KnownValues.FieldInternal, IconSettings.IconAndText),
      Shortcuts = new[]
      {
          new CommandShortcutConfiguration(ModifierKey.LeftAlt, Key.C, ModifierKey.LeftAlt,  Key.VK_OEM_COMMA) 
      }
  };

My question is there doesn't seem to be a way to show the Keybindings/Shortcut in the menu, either in the MenuConfiguration that has the command or the ComandConfiguration of the command.

Am I missing something, or is this just not yet implemented?

@joshdavidson613
Copy link
Author

joshdavidson613 commented Sep 8, 2024

Ok, I can now report a bug. As you can see in the above comment, the Placements property is commented out. That is because I set the Command as a sub-menu item in ExetnsionsEntrypoint.cs:

[VisualStudioContribution]
public static MenuConfiguration CommentScribeExtensionMenu => new MenuConfiguration("MyCommands")
{
    Placements = new[] { CommandPlacement.KnownPlacements.ExtensionsMenu },
    Children = new MenuChild[]
    {
        MenuChild.Command<Command1>(),
        MenuChild.Command<Command2>()
    },
};

In this configuration, no Shortcuts/Keybindings are shown.

However, if I remove the Commands from this config, and use the Placements property on the command itself, the individual menu item shows up with Shortcuts/Keybindings.

Thuse the bug is this:

Commands that have direct placement show the shortcuts/keybindings.
Commands are are Children in other MenuConfiguration items do not show shortcuts/keybindings.

Expected behavior:

Commands in menu items, no matter how placed, will always show shortcuts/keybindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants