Skip to content

Allow extensions to override command title and/or icon in menu placement (in package.json) #34048

@eamodio

Description

@eamodio
  • VSCode Version: Code - Insiders 1.17.0-insider (c354fca, 2017-09-08T05:24:34.310Z)
  • OS Version: Windows_NT x64 10.0.16281

It would be very helpful (and powerful) if there was the ability to override a command's title and/or icon when a command was placed. This would allow for more context sensitive titles/icons without having to resort to multiple commands.

There are multiple places in GitLens where I wished I had this ability (because often the multiple commands just isn't worth the extra complexity) -- where I want a different title for the command palette, editor context, etc, etc.

This is somewhat similar to #32526 - @jrieken I think this could also address that one -- since you could just have the same command listed twice with a different title/icon based on the when clause

Here is my ideal example below:

"commands": [
    {
        "command": "gitlens.stashSave",
        "title": "Stash All Changes",
        "category": "GitLens",
        "icon": {
            "dark": "images/dark/icon-stash.svg",
            "light": "images/light/icon-stash.svg"
        }
    }
],
"menus": {
    "commandPalette": [
        {
            "command": "gitlens.stashSave",
            "when": "gitlens:enabled",
            "icon": {
                "dark": "images/dark/icon-stash-all.svg",
                "light": "images/light/icon-stash-all.svg"
            }
        }
    ],
    "scm/resourceGroup/context": [
        {
            "command": "gitlens.stashSave",
            "when": "gitlens:enabled",
            "title": "Stash Changed Files"
        }
    ],
    "scm/resourceState/context": [
        {
            "command": "gitlens.stashSave",
            // listHasMultipleSelections of course doesn't exist today but it would be SO nice :)
            "when": "gitlens:enabled && !listHasMultipleSelections",
            "title": "Stash File"
        },
        {
            "command": "gitlens.stashSave",
            // listHasMultipleSelections of course doesn't exist today but it would be SO nice :)
            "when": "gitlens:enabled && listHasMultipleSelections", 
            "title": "Stash Files"
        }
    ]
}

I've also included in this example listHasMultipleSelections (or something like it -- no selection, single selection, multiple selections would be ideal) that would be very helpful to have again to be more context-sensitive.

Reproduces without extensions: Yes/No

Metadata

Metadata

Assignees

Labels

menusMenu items and widget issuesunder-discussionIssue is under discussion for relevance, priority, approach

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions