microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.46k stars 29.36k forks source link

[VSCode Extension API] Allow extensions to define custom disabled messages when a command is disabled #229860

Open eric-nguyen-cs opened 1 month ago

eric-nguyen-cs commented 1 month ago

When a command is disabled through the enablement property, the editor and explorer menus simply render a disabled button that shows the command.title as a tooltip. It would be great to have the ability to customize the tooltip for the disabled button to show a custom error message instead.

An example of what the API could like:

{
  "contributes": {
    "commands": [
      {
        "command": "extension.sayHello",
        "title": "Hello World",
        "enablement": "editorLangId == markdown && !isLinux",
        "error": {
          "editorLandId != markdown": "This command is only available in markdown files",
          "isLinux": "This command is only available on Linux"
        }
      }
    ]
  }
}

Another way to do it would be to allow developers to control the tooltip through a custom context variable

{
  "contributes": {
    "commands": [
      {
        "command": "extension.sayHello",
        "title": "Hello World",
        "enablement": "editorLangId == markdown && !isLinux",
        "tooltip": "extension.sayHello.tooltip"
      }
    ]
  }
}
vs-code-engineering[bot] commented 1 month ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

vs-code-engineering[bot] commented 1 month ago

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!