diff --git a/.github/workflows/tct.yml b/.github/workflows/tct.yml index 0449dd1..84aa970 100644 --- a/.github/workflows/tct.yml +++ b/.github/workflows/tct.yml @@ -8,14 +8,12 @@ jobs: matrix: os: - ubuntu-latest - - windows-latest - - macos-latest fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 # lix - - uses: lix-pm/setup-lix@master + - uses: https://k7izh9.gitea.cloud/kiss-lang/setup-lix@1.0.2 with: lix-version: 15.12.0 diff --git a/tct/src/tct/FileConversionProject.kiss b/tct/src/tct/FileConversionProject.kiss index 7ab159d..2709662 100644 --- a/tct/src/tct/FileConversionProject.kiss +++ b/tct/src/tct/FileConversionProject.kiss @@ -62,9 +62,9 @@ (+= tctContent "${block.id} ${block.locked}\n") (File.saveContent tctFile tctContent)))) -(method :Void _saveBlock [:Block block] +(method :Void _saveBlock [:Block block &opt :Bool lastBlock] (when block.inText - (unless (block.inText.endsWith inBlockTerminator) + (unless (or lastBlock (block.inText.endsWith inBlockTerminator)) (+= block.inText inBlockTerminator))) (File.saveContent "${blockDir}/${block.id}.${inExtension}" block.inText) (when block.outText @@ -92,8 +92,11 @@ (_saveTctFile) - (doFor block blocks - (_saveBlock block)) + (let [lastBlock (blocks.pop)] + (doFor block blocks + (_saveBlock block)) + (_saveBlock lastBlock true) + (blocks.push lastBlock)) (_saveOutputFiles) @@ -123,7 +126,7 @@ ((objectWith [type Insert] blockIndex newBlock) (blocks.insert blockIndex newBlock) (_saveTctFile) - (_saveBlock newBlock)) + (_saveBlock newBlock (= blockIndex (- blocks.length 1)))) ((objectWith [type Delete] blockIndex oldBlock) (when .locked (nth blocks blockIndex) (return false)) (blocks.splice blockIndex 1) @@ -134,7 +137,7 @@ (return false)) (setNth blocks blockIndex newBlock) (_saveTctFile) - (_saveBlock newBlock)) + (_saveBlock newBlock (= blockIndex (- blocks.length 1)))) ((objectWith [type JoinDown] blockIndex oldBlock newBlock) (when (or (isNull newBlock) oldBlock.locked newBlock.locked) (return false)) @@ -142,9 +145,9 @@ // allow subcommands to record their simple step-by-step history, // then return early (return (and - (insertBlock blockIndex "${oldBlock.inText}${newBlock.inText}" "${oldBlock.outText}${newBlock.outText}" false) - (deleteBlock (+ blockIndex 2)) - (deleteBlock (+ blockIndex 1))))) + (deleteBlock (+ blockIndex 1)) + (deleteBlock (+ blockIndex 0)) + (insertBlock blockIndex "${oldBlock.inText}${newBlock.inText}" "${oldBlock.outText}${newBlock.outText}" false)))) (never otherwise)) (changeHistory.push change) (_saveOutputFiles) diff --git a/tct/src/tct/TestMain_.kiss b/tct/src/tct/TestMain_.kiss index 86b09f5..e5c2717 100644 --- a/tct/src/tct/TestMain_.kiss +++ b/tct/src/tct/TestMain_.kiss @@ -47,16 +47,16 @@ // Test block insertion (project.insertBlock 0 "not " "!") (project.insertBlock 2 "not " "!") - (assertExportContents project "not here\n\nnot there" "!\n!\n") + (assertExportContents project "not \n\nhere\n\nnot \n\nthere" "!\n!\n") // Test block deletion (project.deleteBlock 0) - (assertExportContents project "here\n\nnot there" "!\n") + (assertExportContents project "here\n\nnot \n\nthere" "!\n") (assertEquals 6 .length (FileSystem.readDirectory "${project.directory}/blocks")) // Test block editing (project.editBlock 2 "here" "!!!" true) - (assertExportContents project "here\n\nnot here" "!\n!!!\n") + (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n") // Test trying to delete locked block (assert !(project.deleteBlock 2)) @@ -64,22 +64,22 @@ (assert !(project.editBlock 2 "edit" "locked block")) (project.toggleLock 2) (assert (project.deleteBlock 2)) - (assertExportContents project "here\n\nnot " "!\n") + (assertExportContents project "here\n\nnot \n\n" "!\n") // Test undo/redo delete (project.undoChange) - (assertExportContents project "here\n\nnot here" "!\n!!!\n") + (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n") (project.redoChange) - (assertExportContents project "here\n\nnot " "!\n") + (assertExportContents project "here\n\nnot \n\n" "!\n") (project.undoChange) (project.undoChange) // Test undo/redo edit: (assert (project.undoChange)) - (assertExportContents project "here\n\nnot there" "!\n") + (assertExportContents project "here\n\nnot \n\nthere" "!\n") (project.redoChange) - (assertExportContents project "here\n\nnot here" "!\n!!!\n") + (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n") ) (rmrf "test.tct")