pucelle / vscode-run-on-save

Run configured shell commands when a file is saved in vscode, and output configured messages on status bar.
https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save
MIT License
50 stars 11 forks source link

"runOnSave.commandsBeforeSaving" doesn't seem to be working #41

Closed JeremyCaron closed 5 months ago

JeremyCaron commented 5 months ago

Hi, I'm on version 1.7.1 and I'm seeing intellisense support your new "commandsBeforeSaving" option. However, nothing gets executed when I use this versus "runOnSave.Commands". Example:

  "runOnSave.commands": [
    {
        "match": ".*\\.cs$",
        "command": "vsSharper.sortUsings",
        "runIn": "vscode"
    }
  ]

I see this run successfully in the output tab for your extension and my cs file is changed as a result of the command being executed, but when I change to:

  "runOnSave.commandsBeforeSaving": [
    {
        "match": ".*\\.cs$",
        "command": "vsSharper.sortUsings",
        "runIn": "vscode"
    }
  ]

Nothing shows up in the output tab and the cs file I saved doesn't have its usings organized.

I was trying to switch to the latter, because when I use the former, the file changes as a result of the command but it actually doesn't get saved until I save it a second time which isn't the behavior I was shooting for.

Also, I noticed that it seems like there's a typo in your documentation, it's saying the option is called "runOnSave.commandBeforeSaving" (command not pluralized) rather than "runOnSave.commandsBeforeSaving".

Thanks for your consideration.

JeremyCaron commented 5 months ago

Took a look at your code and finally realized the error of my ways! The proper syntax was this:

  "runOnSave.commands": [
    {
        "match": ".*\\.cs$",
        "commandBeforeSaving": "vsSharper.sortUsings",
        "runIn": "vscode"
    }
  ]

Working great now!!

Where I got confused is that your README says runOnSave.commandBeforeSaving in the Config section, and mentions nothing about commandBeforeSaving in the Command Options section.

pucelle commented 5 months ago

Sorry, I wrongly updated the readme... will fix it soon.

pucelle commented 5 months ago

Readme will be updated at next release v1.7.2, thanks.