(awaitCommands) macro

This commit is contained in:
2021-11-30 12:45:18 -07:00
parent ed8e038ffa
commit 83d74bcd8b

View File

@@ -38,6 +38,19 @@
(set promise (promise.then iteration)))
promise))
(defMacro awaitCommands [commandsAndArgs &builder b &body body]
(let [commandsAndArgs
(if (isListExp commandsAndArgs)
(.copy (expList commandsAndArgs))
(throw (CompileError.fromExp commandsAndArgs "First argument to awaitCommands should be a list of commands with optional argument arrays")))
bindings []]
(while commandsAndArgs
(bindings.push (b.symbol "_"))
(let [nextCommand (commandsAndArgs.shift)]
(bindings.push (b.callSymbol "executeCommand"
(concat [nextCommand] (if (and commandsAndArgs (isListExp (first commandsAndArgs))) (expList (commandsAndArgs.shift)) []))))))
`(awaitLet ,bindings ,@body)))
// Other
(defAlias &call showTextDocument Vscode.window.showTextDocument)