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

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

Closed
eamodio opened this issue Sep 8, 2017 · 11 comments
Assignees
Labels
menus Menu items and widget issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@eamodio
Copy link
Contributor

eamodio commented Sep 8, 2017

  • 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

@vscodebot vscodebot bot added the insiders label Sep 8, 2017
@jrieken jrieken added the under-discussion Issue is under discussion for relevance, priority, approach label Sep 11, 2017
@chrmarti chrmarti removed the insiders label Sep 27, 2017
@eamodio
Copy link
Contributor Author

eamodio commented Apr 30, 2018

FYI, the example provided above is very simplistic, but this is a real world problem for me with GitLens and others. Changing the title/icon based on a condition would allow for drastically reduced complexity for extension authors and better usability for users through better contextual titles/icons.

To achieve this effect today, you need to create duplicate commands for all the possible usages where the title or icon should change. In GitLens I take that approach in some cases, but in others the extra complexity is just too high to pay the price of all the duplication.

@jrieken jrieken added the *out-of-scope Posted issue is not in scope of VS Code label Sep 10, 2018
@vscodebot
Copy link

vscodebot bot commented Sep 10, 2018

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@vscodebot vscodebot bot closed this as completed Sep 10, 2018
@eamodio
Copy link
Contributor Author

eamodio commented Sep 11, 2018

😢 I really wish this (or something similar) can be reconsidered. I really find dealing with commands with many different contexts very difficult to deal with and leads to so much duplication in the package.json

@eamodio
Copy link
Contributor Author

eamodio commented Mar 6, 2020

@jrieken Any chance we can revisit this? I still would find it valuable to be able to at least change the title of a command in its placement.

@eamodio eamodio reopened this Mar 20, 2020
@eamodio eamodio removed the *out-of-scope Posted issue is not in scope of VS Code label Mar 20, 2020
@jrieken
Copy link
Member

jrieken commented Mar 23, 2020

👎 this is still against the design of the commands and how we utilise them. And you still didn't answer the question why it should be called "Save" in the global menu and "Delete" in the context menu.

@Tyriar
Copy link
Member

Tyriar commented Jun 5, 2020

I think I'm in the right place... I'd also like something like this so I could contribute several numbered commands to the context menu based on settings for Tyriar/vscode-windows-terminal#5

For example:

"windowsTerminal.customMenuItem1.enabled": true,
"windowsTerminal.customMenuItem1.profile": "PowerShell"
"windowsTerminal.customMenuItem2.enabled": true,
"windowsTerminal.customMenuItem2.profile": "MSYS2"

With context contributions:

"menus": {
  "explorer/context": [
    {
      "command": "vscode-windows-terminal.customMenuItem1",
      "when": "config.windowsTerminal.customMenuItem1.enabled",
      "title": "Open in Windows Terminal (${config.windowsTerminal.customMenuItem1.profile})"
    }
    {
      "command": "vscode-windows-terminal.customMenuItem2",
      "when": "config.windowsTerminal.customMenuItem2.enabled",
      "title": "Open in Windows Terminal (${config.windowsTerminal.customMenuItem2.profile})"
    }
  ]
}

Without something like this I think I need to either just stick with numbers to differentiate them in the context menu which are not user friendly, or enumerate every common possibility and uncommon titles just miss out.

@eamodio
Copy link
Contributor Author

eamodio commented Jun 5, 2020

Allowing dynamic titles in this way (from context key values) would be awesome -- GitLens has the same issue when dealing with opening things (commits, files, branches, repos, etc) on a remote (GitHub, Bitbucket, etc). Right now I use Open x on Remote, but it would be awesome to be able to much more easily say Open x on GitHub when I know that the remote is GitHub.

@Tyriar
Copy link
Member

Tyriar commented Jun 5, 2020

@eamodio would GitLens be able to fill in GitHub, Bitbucket, etc. using something before activation?

@eamodio
Copy link
Contributor Author

eamodio commented Jun 5, 2020

No, but we already are already evaluating whether or not to show the menu based on those context keys.

@zhfnjust
Copy link

we need this

"commands": [
    {
        "command": "gitlens.stashSave",
        "title": "Stash All Changes",     //long name
        "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"
            }
        }
    ],
    "view/item/context": [
        {
            "command": "gitlens.stashSave",
            "when": "gitlens:enabled",
            "title": "Stash"    //it's a  button, short name
        }
    ],
}

@jrieken
Copy link
Member

jrieken commented Jun 16, 2021

We have no plans for placement specific titles or icons. All information that is needed to present a command must be on the command itself. If it would be on the menu, that information is locked-in, needs to be potentially duplicated per placement, and is a show-stopper for customizable menus.

This doesn't mean that there is no need for a short name and long name but it must be on the command, not the menu. With that menu implements decide what property to use, e.g already today the command palette menu uses the title and category property whereas other menus only use the title property.

In fact, internally we added support for shortTitle which complements title (af0c01b). I will close this issue and create a new issue to track making this usable by extensions.

@jrieken jrieken closed this as completed Jun 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
menus Menu items and widget issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

5 participants