Skip to content

Conversation

@AlteredConstants
Copy link

@AlteredConstants AlteredConstants commented May 22, 2017

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).

@geddski
Copy link
Owner

geddski commented May 22, 2017

Looks pretty good! Have you tested to be sure it runs them in the right order then?

@AlteredConstants
Copy link
Author

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.

@mizagog
Copy link

mizagog commented Jul 17, 2017

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.

@AlteredConstants
Copy link
Author

@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.

@osdavison
Copy link

@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

@rsxdalv
Copy link

rsxdalv commented Oct 26, 2018

@nicchristeller
Copy link

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" ]

@vintprox
Copy link

bump,
still not merged?

@Dimfred
Copy link

Dimfred commented Jul 23, 2021

bump

@EduYukio
Copy link

EduYukio commented Jul 3, 2024

bump
this is awesome, it solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown configuration setting

10 participants