geddski / macros

macros support for VS Code
MIT License
165 stars 36 forks source link

commands order not always working well #41

Open kobi2187 opened 5 years ago

kobi2187 commented 5 years ago

I have mixed results with a macro I am using. I am using both the current find widget, and the search files panel. activating the next match, and then the find widget. But sometimes the find widget executes before the search match. At least, that's what I deem is happening... Are the commands happening one after another? Can it be an async problem? Is there a way that I can add a little delay (sleep?), or wait for focus? If there is a better way to contact and debug this together, please let me know.

leetschau commented 5 years ago

I face the same problem:

      "runHaskellCode": [
        {
          "command": "workbench.action.terminal.sendSequence",
          "args": { "text": ":{" }
        },
        "workbench.action.terminal.runSelectedText",
        {
          "command": "workbench.action.terminal.sendSequence",
          "args": { "text": ":}" }
        }
      ]

The text received by the terminal is:

:{:} // the text selected

But what I want is:

:{
// the text selected
:}
rsxdalv commented 5 years ago

This is caused by delay in the editor, to verify it you can add a bunch of write commands (and you'll see that they eventually write in the find window)

Solution: https://github.com/geddski/macros/pull/13

steelcracker commented 5 years ago

Stumbled upon this too. Downloaded the extension and started to write a heavy macro and right from the start this order thing happened. Here is the example:

"refactorExtractLocaleString": [
    "editor.action.smartSelect.grow",
    "editor.action.smartSelect.grow",
    "editor.action.clipboardCopyAction",
    //{"command": "type", "args": {"text": "["}}
]

This should select a string literal surrounded with quotes and copy it to the clipboard. But CopyAction runs before selection and copies the entire line. The next thing I was going to add was a keypress action to surround the literal with brackets which also didn't work as expected..

11 solved the issue