emeraldwalk / vscode-runonsave

Visual Studio Code extension to run commands whenever a file is saved.
Apache License 2.0
182 stars 57 forks source link

delay before command runs #82

Closed Daviid-P closed 1 year ago

Daviid-P commented 1 year ago

Sometimes I made small changes and press ctrl + s by muscle memory.

Would it be possible to add some kind of delay so that it waits n milliseconds before running the command and if before that time the document is saved again the timer starts again from n?

EyMaddis commented 1 year ago

I think runOnSave runs only again after the first command finishes unless you are using isAsync: true. And a delay can be done by sleep 1 && ./yourCommand (waits 1 second)

Daviid-P commented 1 year ago

Wouldn't that still run the command as many times as I pressed save?

What I'm looking for is a delay before running the command so however many times I press save, the timer gets reset and at the end, if the timer runs out, the command is run only once.

EyMaddis commented 1 year ago

Could be but you need to try it out :) You could work around it by adapting a script that writes a simple lock file somewhere, like .runOnSaveLock. If that file exists, skip execution. Looking at the state of this repo, I guess you would need to introduce it via a PR yourself, if you want it

Daviid-P commented 1 year ago

I didn't even notice last update was 4 years ago, I'll go with the lock file.