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