tjx666 / open-in-external-app

Open file with external application in VSCode
https://marketplace.visualstudio.com/items?itemName=YuTengjing.open-in-external-app
MIT License
52 stars 9 forks source link

[FR] fallback vs. shared commands #45

Open huyz opened 1 year ago

huyz commented 1 year ago

Right now it seems that this extension supports a fallback: if I have * as the extensionName and the current file's extension doesn't match any other rule, then this fallback rule works. That's great. (By the way, I didn't see that documented, so I had to guess and I was pleasantly surprised that it worked.)

However, I'd also like to have a set of editors that apply to all extensions, even if there is a match. For example, I want to have MacVim as an option for all extensions. But if I'm invoking on an md file, I will only get my configured MarkText as a command.

The workaround is for me is to duplicate the MacVim command under both the md and the * rules.

So in addition to supporting a * rule, maybe there should be a _common_ or _all_ rule

tjx666 commented 1 year ago

For example:

"openInExternalApp.openMapper": [
        {
            "extensionName": ["jsxbin", "jsx"],
            "apps": "Adobe Photoshop 2022",
        },
        {
            "extensionName": "shared",
            "apps": "MacVim"
        }
    ],

When I open .jsxbin file, will both open Photoshop and MacVim?

huyz commented 1 year ago

Yes, like that. But of course with a special extensionName that isn't like to conflict; so something like noticeable like _ALL_

tjx666 commented 1 year ago

This is also supported in latest version by extensionName __ALL__

huyz commented 1 year ago

This doesn't work for me:

  "openInExternalApp.openMapper": [
    {
      "apps": [
        {
          "shellCommand": "mvim --servername Code --remote-tab-silent '+chdir ${fileWorkspaceFolder}|call cursor(${cursorLineNumber},${cursorColumnNumber})|call feedkeys(\"z.\")' '${file}'",
          "title": "MacVim"
        },
        {
          "shellCommand": "vimr --remote-tab-silent --nvim '+chdir ${fileWorkspaceFolder}|call cursor(${cursorLineNumber},${cursorColumnNumber})|normal z.' '${file}'",
          "title": "VimR"
        },
        {
          "shellCommand": "idea --line ${cursorLineNumber} '${fileWorkspaceFolder}' '${file}'",
          "title": "IntelliJ IDEA"
        }
      ],
      "extensionName": "__ALL__"
    },

It's not possible to have shellCommands be inherited?

tjx666 commented 1 year ago

You want all the apps to be executed? Anytime pr welcome.