Skip to content

Placing a Command Group in two places duplicates the group's commands #567

@ArcanoxDragon

Description

@ArcanoxDragon

I have a configuration similar to the following in my extension (I have simplified it for this example):

internal class MyExtension : Extension
{	
	public static class Groups
	{
		public static CommandGroupConfiguration MyGroup => new() {
			Children = [
				GroupChild.Command<MyCommand>(),
			],
		};
	}
	
	public static class Menus
	{
		[VisualStudioContribution]
		public static MenuConfiguration SubMenu => new("%Menus.SubMenu.DisplayName%") {
			Children = [
				MenuChild.Group(Groups.MyGroup),
				MenuChild.Command<MyOtherCommand>(),
			],
		};

		[VisualStudioContribution]
		public static MenuConfiguration MainMenu => new("%Menus.MainMenu.DisplayName%") {
			Placements = [
				CommandPlacement.KnownPlacements.ExtensionsMenu,
			],
			Children = [
				MenuChild.Menu(SubMenu),
				MenuChild.Separator,
				MenuChild.Command<AboutCommand>(),
			],
		};
	}
	
	[VisualStudioContribution]
	public static ToolbarConfiguration MainToolbar => new("%Toolbars.MainToolBar.DisplayName%") {
		Children = [
			ToolbarChild.Group(Groups.MyGroup),
		],
	};
}

When I launch Studio, the "MyCommand" command is present twice in both the "SubMenu" menu as well as on the extension toolbar (four icons total - two in the SubMenu, two on the toolbar).

If I comment out MenuChild.Group(Groups.MyGroup) in the toolbar configuration or the sub-menu configuration, the command only appears once in the place where I didn't comment out the group child. It seems like the group being present in two different places is just duplicating the contents of the group everywhere it appears.

The documentation seems to suggest that this is an explicitly supported use case, but it does not actually work as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions