ryuta46 / vscode-multi-command

Visual Studio Code Plugin named multi-command
MIT License
229 stars 14 forks source link

Add `language` configuration to each sequence #59

Closed Yarakashi-Kikohshi closed 2 years ago

Yarakashi-Kikohshi commented 2 years ago

Expected behavior

  1. Open a file in a specific language.
  2. Run Multi command: Execute multi command in command palette.
  3. Sequence displayed:
    • configured in a specific language.
    • without language configuration.

Also, if the sequence specifies a particular language, it will only be executed when a file in that language is open. If you do not use this configuration, the default values are for all languages.

Reasons why language is needed

A sequence of commands related to editing provided by VSCode does not matter for language differences.

However, without language configuration, it can cause commands for a particular language to malfunction, such as those provided by extensions.

Of course, you can avoid problems by assigning keybindings to sequence commands. But I don't want to put the effort into assigning keybindings to every sequence command.

In addition, if you have registered a large number of sequences without language configuration, it is difficult to see and select from the command palette.

To prevent malfunctions and make the display in the command palette easier to read, I recommend that you hide the sequences for languages that are not related to the active file.

Demonstration configuration

  "multiCommand.commands": [
    {
      "command": "multiCommand.demo.python",
      "sequence": [
        // ...
      ],
      "language": ["python"]
    },
    {
      "command": "multiCommand.demo.typejava",
      "sequence": [
        // ...
      ],
      "language": ["typescript", "javascript"]
    },
  ]

When opening a 'python' file, only multiCommand.demo.python appears in the command palette and is executable. multiCommand.demo.typejava applies only to 'typescript' and 'javascript', so it is not displayed and cannot be executed.

Source of idea

In bhughes339.replacerules, the following configurations are possible.

languages - (Optional) An array of workspace language ids that the rule is restricted to. For example, a rule with languages set to 'typescript' will only appear in the Run Rule... menu if TypeScript is the selected language for the active document.

https://github.com/bhughes339/vscode-replacerules#configuration-options

ryuta46 commented 2 years ago

Implemented in 1.6.0. See Manual Execution in README.

Please reopen this issue or create new issue if you have any problem about this feature. Thanks.