macros
macros copied to clipboard
Custom delay command
This solved a specific problem I was having, and since there was discussion in #9 about delays, I figured this might be generally useful.
Specifically, this adds $delay
as a command (taking one argument, the delay length in milliseconds), e.g.
"macros": {
"addSemicolon": [
"cursorEnd",
{"command": "$delay", "args": {"milliseconds": 1000}},
{"command": "type", "args": {"text": ";"}}
]
}
I also fixed #5, incidentally solved the same problem as in PR #11, and removed the dependency on promise-series
(I was having a harder time following the code with it in there and it didn't seem necessary).
Looks pretty good! Have you tested to be sure it runs them in the right order then?
It worked in practice in my specific circumstance and the reduce operation should chain them correctly in general, but I didn't specifically validate the ordering. I could potentially write some unit tests for it, but I'd have to familiarize myself with the VSCode tooling first (I've not written code for an extension before).
To be clear, I didn't try to figure out why the vscode.commands.executeCommand
function seemed to resolve its promise before the underlying action was fully complete (in my instance, a Setting Cycler action followed by a save action) so this might be an underlying problem better solved with something other than a delay.
is this going in? can't wait to have it! i have a few issues with commands running to fast, and i think a delay option will sort it out.
@geddski Was there anything more you needed from me or other concerns before merging? I've been using my own custom build, but it might help some other people (and be more convenient for me) if it were published.
@geddski Bump. I'd love to see this merged in. I've been using a custom build as well, but others have been asking for this
https://marketplace.visualstudio.com/items?itemName=l7ssha.macrosRe
https://marketplace.visualstudio.com/items?itemName=l7ssha.macrosRe
Installed this and it fixed my issues without even needing to insert a delay, so it seems to be fixing some other issues as well - the macro below did not work with the main macros
extension but did with the fork.
"selectAndCopyCursorToNextMatch": [ "editor.action.smartSelect.grow", "editor.action.addSelectionToNextFindMatch" ]
bump, still not merged?
bump
bump this is awesome, it solved my problem