fix quickPick functions + add withValueOrQuickPick macros

This commit is contained in:
2021-10-22 19:34:42 -04:00
parent 62b7355e34
commit 5783d510e9

View File

@@ -22,11 +22,11 @@
(function quickPick [:Array<String> strings]
(awaitLet [chosenItem (_quickPick (for string strings (quickPickItem string)))]
chosenItem.label))
(when chosenItem chosenItem.label)))
(function quickPickMap [:Map<String,Dynamic> stringMap]
(awaitLet [chosenItem (_quickPick (for =>key value stringMap (quickPickItem key (Std.string value))))]
(dictGet stringMap chosenItem.label)))
(when chosenItem (dictGet stringMap chosenItem.label))))
// commands
(defAlias &call executeCommand Vscode.commands.executeCommand)
@@ -45,6 +45,18 @@
(awaitLet [,v (inputBox)]
,@body)))
(defMacro withValueOrQuickPick [v options &body body]
`(if ,v
{,@body}
(awaitLet [,v (quickPick ,options)]
,@body)))
(defMacro withValueOrQuickPickMap [v options &body body]
`(if ,v
{,@body}
(awaitLet [,v (quickPickMap ,options)]
,@body)))
// This has to be a macro so it can return from tryLoadConfig
(defMacro trySpawnSync [command args options onError]
`(let [command ,command