sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
812 stars 39 forks source link

Platform Specific Command Palette Entries #3188

Closed deathaxe closed 3 years ago

deathaxe commented 4 years ago

Problem description

A plugin might want to provide platform specific commands or just different labels for the same command in a Menu or Command Palette.

Example

The FileManager plugin provides the fm_open_in_explorer command, which is labeled "Open in Explorer" on Windows and Linux while using "Open in Finder" on MacOS.

While it is easy to do for any kind of menu (e.g.: Side Bar.sublime-menu):

[
    {
        "caption": "Open in Explorer",
        "platform": "!OSX",
        "command": "fm_open_in_explorer",
        "args": {
            "paths": []
        }
    },
    {
        "caption": "Open in Finder",
        "platform": "OSX",
        "command": "fm_open_in_explorer",
        "args": {
            "paths": []
        }
    },
]

... the command needs to specify its own visible_on_platforms argument to handle the different labels in the Command Palette at the moment.

Preferred solution

Add support for the platform key in the Default.sublime-commands file the same way it is used in the Main.sublime-menu.

[
    {
        "caption": "File Manager: Open In Explorer",
        "command": "fm_open_in_explorer",
        "platform": ["Windows", "Linux"]
    },
    {
        "caption": "File Manager: Open In Finder",
        "command": "fm_open_in_explorer",
        "platform": "OSX"
    },
]

Alternatives

Add support for platform specific Default.sublime-commands files the same way as it is used for Default.sublime-keybindings

BenjaminSchaaf commented 3 years ago

Fixed in build 4094. The "platform" key can now be used for commands just like it can for menus.