Finish Kiss-VScode overhaul first pass

This commit is contained in:
2023-03-10 13:26:50 -07:00
parent 626cc9f350
commit 782f1d1f94
7 changed files with 38 additions and 22 deletions

View File

@@ -298,4 +298,7 @@
(otherwise (throw "Unsupported operating system"))))) (otherwise (throw "Unsupported operating system")))))
(function :Void osOpenFileInDir [&opt :String dir] (function :Void osOpenFileInDir [&opt :String dir]
(chooseFileInDir osOpenFile false dir)) (chooseFileInDir osOpenFile false dir))
(function :Void printThroughInfoMessage []
(set Prelude.printStr ->s (infoMessage s)))

View File

@@ -51,8 +51,8 @@
}, },
{ {
"command": "kiss.insertUTestCase", "command": "kiss.insertUTestCase",
"mac": "Cmd+; Cmd+u", "mac": "Cmd+; Cmd+t Cmd+c",
"key": "Ctrl+; Ctrl+u" "key": "Ctrl+; Ctrl+t Ctrl+c"
}, },
{ {
"command": "kiss.mapLinesSync", "command": "kiss.mapLinesSync",
@@ -63,6 +63,16 @@
"command": "kiss.sortLinesSync", "command": "kiss.sortLinesSync",
"mac": "Cmd+; Cmd+l Cmd+s", "mac": "Cmd+; Cmd+l Cmd+s",
"key": "Ctrl+; Ctrl+l Ctrl+s" "key": "Ctrl+; Ctrl+l Ctrl+s"
},
{
"command": "kiss.updateExtension",
"mac": "Cmd+; Cmd+u",
"key": "Ctrl+; Ctrl+u"
},
{
"command": "kiss.testAndUpdateExtension",
"mac": "Cmd+; Cmd+t Cmd+u",
"key": "Ctrl+; Ctrl+t Ctrl+u"
} }
], ],
"commands": [ "commands": [
@@ -89,6 +99,14 @@
{ {
"title": "Kiss-Vscode: Sort the selected text lines using a (String,String)->Int comparator function", "title": "Kiss-Vscode: Sort the selected text lines using a (String,String)->Int comparator function",
"command": "kiss.sortLinesSync" "command": "kiss.sortLinesSync"
},
{
"title": "Kiss-Vscode: Update and reinstall the Kiss-Vscode extension you are editing",
"command": "kiss.updateExtension"
},
{
"title": "Kiss-Vscode: Check test.sh, then update and reinstall the kiss-vscode extension you are editing",
"command": "kiss.testAndUpdateExtension"
} }
], ],
"languages": [ "languages": [

View File

@@ -2,6 +2,7 @@
(loadFrom "kiss-vscode-api" "src/KissUtil.kiss") (loadFrom "kiss-vscode-api" "src/KissUtil.kiss")
(function _activate [:ExtensionContext context] (function _activate [:ExtensionContext context]
(printThroughInfoMessage)
(load "commands/ExtensionTools.kiss") (load "commands/ExtensionTools.kiss")
(load "commands/KissTools.kiss") (load "commands/KissTools.kiss")
(load "commands/Lines.kiss")) (load "commands/Lines.kiss"))

View File

@@ -1,7 +1,7 @@
(loadFrom "kiss-vscode-api" "src/Util.kiss") (loadFrom "kiss-vscode-api" "src/Util.kiss")
(function kvLibpath [] (.trim (assertProcess "haxelib" ["libpath" "kiss-vscode"]))) (function extensionPath [] .fsPath .uri (first Vscode.workspace.workspaceFolders))
(function :ChildProcessSpawnSyncOptions options [] (object cwd (let [path (kvLibpath)] (path.substr 0 (- path.length 1))))) (function :ChildProcessSpawnSyncOptions options [] (object cwd (extensionPath)))
(function handleUpdateFailure [error] (function handleUpdateFailure [error]
(showCompileError "Error updating Kiss-VSCode: $error") (showCompileError "Error updating Kiss-VSCode: $error")
@@ -14,25 +14,20 @@
(return) (return)
}) })
(function :Void updateKissVscode [&opt _] (defCommand context kiss.updateExtension "Update and reinstall the Kiss-Vscode extension you are editing" "C-; C-u" []
(trySpawnSync "haxe" ["build.hxml"] (options) forceUpdateFailure)
(if (= "Windows" (Sys.systemName)) (if (= "Windows" (Sys.systemName))
{ (trySpawnSync "cmd.exe" ["/c" "npm" "install"] (options) forceUpdateFailure)
(trySpawnSync "cmd.exe" ["/c" "npm" "install"] (options) forceUpdateFailure) (trySpawnSync "npm" ["install"] (options) forceUpdateFailure))
(trySpawnSync "cmd.exe" ["/c" "vsce" "package"] (options) forceUpdateFailure) (trySpawnSync "haxe" ["build.hxml"] (options) forceUpdateFailure)
}
{
(trySpawnSync "npm" ["install"] (options) forceUpdateFailure)
(trySpawnSync "vsce" ["package"] (options) forceUpdateFailure)
})
(awaitLet [_ (executeCommand (awaitLet [_ (executeCommand
"workbench.extensions.command.installFromVSIX" "workbench.extensions.command.installFromVSIX"
(Uri.file (joinPath (kvLibpath) (last (filter (FileSystem.readDirectory (kvLibpath)) ->file (file.endsWith ".vsix"))))))] (Uri.file (joinPath (extensionPath) (last (filter (FileSystem.readDirectory (extensionPath)) ->file (file.endsWith ".vsix"))))))]
(catch [error] (catch [error]
(handleUpdateFailure error))) (handleUpdateFailure error)))
{}) {}
null)
(function testAndUpdateKissVscode [&opt _] (defCommand context kiss.testAndUpdateExtension "Check test.sh, then update and reinstall the kiss-vscode extension you are editing" "C-; C-t C-u" []
(trySpawnSync "test.sh" [] (options) handleUpdateFailure) (trySpawnSync "test.sh" [] (options) handleUpdateFailure)
(updateKissVscode)) (kiss_updateExtension))

View File

@@ -55,7 +55,7 @@ class ${className} {}
(defCommand context kiss.showCorrespondingFile "Open the corresponding .kiss/.hx file to this one" "C-; C-f" [] (defCommand context kiss.showCorrespondingFile "Open the corresponding .kiss/.hx file to this one" "C-; C-f" []
(showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor)))) (showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor))))
(defCommand context kiss.insertUTestCase "Generate a UTest test case in this .hx/.kiss file" "C-; C-u" [] (defCommand context kiss.insertUTestCase "Generate a UTest test case in this .hx/.kiss file" "C-; C-t C-c" []
(awaitLet [testName (inputBox) (awaitLet [testName (inputBox)
&sync testName &sync testName
"$(.toUpperCase (testName.substr 0 1))$(testName.substr 1)" "$(.toUpperCase (testName.substr 0 1))$(testName.substr 1)"

View File

@@ -1,4 +1,3 @@
#! /bin/bash #! /bin/bash
# Run the build without -D test first, to make sure it works that way too: haxe build.hxml
echo "!test" && haxe build.hxml && echo "test" && haxe -D test build.hxml -cmd "node bin/extension.js"