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

Possible to use selected text as variable on save? #32

Closed christopherball closed 9 months ago

christopherball commented 10 months ago

Context:

I'd like to issue a terminal command 'on save', that follows the following format:

command -flag **selected text**

From reading through the docs it doesn't appear that this is possible correct? This would be super useful (at least for my workflow).

jackwhelpton commented 10 months ago

I've got a PR raised at the moment that reworks the variable substitution logic, which seems the ideal way to do this:

https://code.visualstudio.com/docs/editor/variables-reference

${selectedText} - the current selected text in the active file

I've added that capability this morning and it looks good to me:

https://github.com/pucelle/vscode-run-on-save/pull/30

This is my first time dabbling with VS Code extensions, though, so I could do with feedback from the original author; I've probably made a bunch of howling mistakes. If you want to pull that branch and see if it works for you, that'd be great.

christopherball commented 10 months ago

Thanks for adding this ask into your PR.

Can't say that I'm familiar with testing extensions manually. Out of curiosity, do you have any details on how to go about this on mac? Presumably we're talking about manually dropping files into a particular extension folder since we'd be bypassing the standard front door install method within VSCode?

jackwhelpton commented 10 months ago

I'm pretty new to this area too, I'm afraid, so I'm not sure about installing an extension manually. For debugging/testing, I've been loading the extension code itself and launching it via VS Code; that opens up a fresh instance in "extension host" mode, with only this plugin loaded.

pucelle commented 9 months ago

v1.7.0 is released and supports this, thanks for jackwhelpton's PR.