diff --git a/projects/kiss-vscode/src/Util.kiss b/projects/kiss-vscode/src/Util.kiss index c5d8483a..7c87d865 100644 --- a/projects/kiss-vscode/src/Util.kiss +++ b/projects/kiss-vscode/src/Util.kiss @@ -22,11 +22,11 @@ (function quickPick [:Array strings] (awaitLet [chosenItem (_quickPick (for string strings (quickPickItem string)))] - chosenItem.label)) + (when chosenItem chosenItem.label))) (function quickPickMap [:Map 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