diff --git a/projects/kiss-vscode/config/KissConfig.kiss b/projects/kiss-vscode/config/KissConfig.kiss index 9bffcb33..d078b783 100644 --- a/projects/kiss-vscode/config/KissConfig.kiss +++ b/projects/kiss-vscode/config/KissConfig.kiss @@ -272,13 +272,15 @@ // Way to more forgivingly get long text inputs (function :Promise inputEditor [:String filename :String prompt] - (let [tempFile (joinPath extensionPath "temp" filename) + (let [previousEditor activeTextEditor + tempFile (joinPath extensionPath "temp" filename) uri (if (FileSystem.exists tempFile) (Uri.parse "file:$tempFile") (Uri.parse "untitled:$tempFile"))] (new Promise ->[resolve reject] (awaitLet [doc (openTextDocument uri) + _ (doc.save) editor (showTextDocument doc)] (print "Enter ${prompt}, then save and close this editor.") (let [&mut :Disposable closeEvent null] @@ -287,7 +289,8 @@ ->closedDoc (when (= closedDoc.fileName doc.fileName) (closeEvent.dispose) - (if editor.document.isDirty (reject "Input editor for $prompt was closed without saving.") (resolve (doc.getText))))))))))) + (awaitLet [_ (showTextDocument previousEditor.document)] + (if editor.document.isDirty (let [error "Input editor for $prompt was closed without saving."] (warningMessage error) (reject error)) (resolve (editor.document.getText)))))))))))) (#unless test (var :Array conversions []) diff --git a/projects/kiss-vscode/src/commands/MapLines.kiss b/projects/kiss-vscode/src/commands/MapLines.kiss index 63624322..372fa846 100644 --- a/projects/kiss-vscode/src/commands/MapLines.kiss +++ b/projects/kiss-vscode/src/commands/MapLines.kiss @@ -16,7 +16,7 @@ (e.insert editor.selection.active mappedText)))))) (function mapLinesSync [&opt selectedText] - (awaitLet [mapFuncStr (inputBox)] + (awaitLet [mapFuncStr (inputEditor "mapLinesFunc.kiss" "a String->String function through which to map the selected lines")] (let [:String->String mapFunc (evalString mapFuncStr)] (_mapLinesSync selectedText mapFunc)))) @@ -31,7 +31,7 @@ (e.insert editor.selection.active (lines.join "\n"))))))) (function sortLinesSync [&opt selectedText] - (awaitLet [compareFuncStr (inputBox)] + (awaitLet [compareFuncStr (inputEditor "sortLinesFunc.kiss" "a (String,String) -> Int function with which to sort the selected lines")] (_sortLinesSync selectedText (if (< 0 compareFuncStr.length) (evalString compareFuncStr) Reflect.compare))))