diff --git a/projects/kiss-vscode/src/Main.kiss b/projects/kiss-vscode/src/Main.kiss index 30fc53bb..93c8eff0 100644 --- a/projects/kiss-vscode/src/Main.kiss +++ b/projects/kiss-vscode/src/Main.kiss @@ -22,7 +22,7 @@ // If there's a build error when testing, throw a test failure (throw errorMessage) // If there's a build error at runtime, tell the user - (Vscode.window.showErrorMessage errorMessage)) + (showCompileError errorMessage)) }] // Choose where to find the custom config diff --git a/projects/kiss-vscode/src/Util.kiss b/projects/kiss-vscode/src/Util.kiss index bab158ee..9a4b617f 100644 --- a/projects/kiss-vscode/src/Util.kiss +++ b/projects/kiss-vscode/src/Util.kiss @@ -23,7 +23,7 @@ (awaitLet [chosenItem (_quickPick (for string strings (quickPickItem string)))] (when chosenItem chosenItem.label))) -(function quickPickMap [:Map stringMap] +(function :js.lib.Promise.Thenable quickPickMap [:Map stringMap] (awaitLet [chosenItem (_quickPick (for =>key value stringMap (quickPickItem key (Std.string value))))] (when chosenItem (dictGet stringMap chosenItem.label)))) @@ -41,6 +41,7 @@ // Other (defAlias &call showTextDocument Vscode.window.showTextDocument) +(defAlias &call openTextDocument Vscode.workspace.openTextDocument) // Macros for implementing commands in Kiss @@ -69,11 +70,31 @@ options ,options result (ChildProcess.spawnSync command args options)] (if result.error - // TODO i can't remember if this needs to be a throw for some reason, - // but it seems like it's supposed to be (,onError ...)(return) like below - (throw "Error $result.error from $command ${args}: $result.stdout $result.stderr") + {(,onError "Error $result.error from $command ${args}: $result.stdout $result.stderr")(return)} (case result.status (0 null) (errCode (,onError "Error code $errCode from $command ${args}: $result.stdout $result.stderr") - (return)))))) \ No newline at end of file + (return)) + (null (,onError "result status is null from $command ${args}: $result.stdout $result.stderr")))))) + +(function :Void showCompileError [errorMessage] + (ifLet [compileErrors (R.distinctMatches + (R.group + (R.namedGroup "file" + (R.repeat (R.oneOf R.anyLetter R.anyDigit (R.escape "/")) 1) // filename + (R.escape ".kiss:") + (R.repeat R.anyDigit 1) // line + (R.escape ":") + (R.optional + (R.group + (R.repeat R.anyDigit 1) // column + (R.escape ":")))) + (R.repeat R.anyChar 1)) + errorMessage)] + { + (Vscode.window.showErrorMessage errorMessage) + (awaitLet [chosen (quickPickMap (for match compileErrors =>match.match match))] + (executeCommand "workbench.action.quickOpen" (substr (chosen.namedGroup "file") 0 -1))) + } + (Vscode.window.showErrorMessage errorMessage))) \ No newline at end of file diff --git a/projects/kiss-vscode/src/commands/ExtensionTools.kiss b/projects/kiss-vscode/src/commands/ExtensionTools.kiss index 49759c87..2f3ae09b 100644 --- a/projects/kiss-vscode/src/commands/ExtensionTools.kiss +++ b/projects/kiss-vscode/src/commands/ExtensionTools.kiss @@ -4,8 +4,9 @@ (function :ChildProcessSpawnSyncOptions options [] (object cwd (let [path (kvLibpath)] (path.substr 0 (- path.length 1))))) (function handleUpdateFailure [error] - (errorMessage "Error updating Kiss-VSCode: $error") - (throw error)) + (showCompileError "Error updating Kiss-VSCode: $error") + (object) + **(throw error)) (function :Void updateKissVscode [&opt _] (trySpawnSync "haxe" ["build.hxml"] (options) handleUpdateFailure)