geddski / macros

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

Trouble getting a save&close macro to work #55

Closed nguerrera closed 4 years ago

nguerrera commented 4 years ago

I wrote the following where my intent is to bind a key to save a document then close it:

"macros": {
    "saveAndCloseActiveEditor":  [
      "workbench.action.files.save",
      "workbench.action.closeActiveEditor"
    ]
  }

However, it doesn't work as I'd hoped as I still get prompted to save the document:

[Window Title]
Visual Studio Code - Insiders

[Main Instruction]
Do you want to save the changes you made to settings.json?

[Content]
Your changes will be lost if you don't save them.

[Save] [Don't Save] [Cancel]

Strangely, it's as though the closeActiveEditor didn't wait for save to complete. If I cancel that dialog, the document is actually saved from the prior macro run, and if I run it again, it will therefore be able to close without the prompt.

Any idea what's going on here and how I might get around it? Thanks!

nguerrera commented 4 years ago

I'm not sure, but it seems like #13 fixes this even without using it to hack in a delay. the macrosRe fork that has that solved the issue for me.

nguerrera commented 4 years ago

https://github.com/ctf0/macros also fixes this