inputEditor allow default contents
This commit is contained in:
@@ -334,26 +334,25 @@
|
|||||||
(insertAt activeTextEditor.selection.active text))
|
(insertAt activeTextEditor.selection.active text))
|
||||||
|
|
||||||
// Way to more forgivingly get long text inputs
|
// Way to more forgivingly get long text inputs
|
||||||
(function :js.lib.Promise<String> inputEditor [:String filename :String prompt]
|
(function :js.lib.Promise<String> inputEditor [:String filename :String prompt &opt :String defaultContent]
|
||||||
(let [previousEditor activeTextEditor
|
(let [previousEditor activeTextEditor
|
||||||
tempFile (joinPath (userHome) "Documents" filename)
|
tempFile (joinPath (userHome) "Documents" filename)]
|
||||||
uri (if (sys.FileSystem.exists tempFile)
|
(sys.io.File.saveContent tempFile (or defaultContent ""))
|
||||||
(Uri.parse "file:$tempFile")
|
(let [uri (Uri.parse "file:$tempFile")]
|
||||||
(Uri.parse "untitled:$tempFile"))]
|
(new js.lib.Promise
|
||||||
(new js.lib.Promise
|
->[resolve reject]
|
||||||
->[resolve reject]
|
(awaitLet [doc (openTextDocument uri)
|
||||||
(awaitLet [doc (openTextDocument uri)
|
_ (doc.save)
|
||||||
_ (doc.save)
|
editor (showTextDocument doc)]
|
||||||
editor (showTextDocument doc)]
|
(print "Enter ${prompt}, then save and close this editor.")
|
||||||
(print "Enter ${prompt}, then save and close this editor.")
|
(let [&mut :Disposable closeEvent null]
|
||||||
(let [&mut :Disposable closeEvent null]
|
(set closeEvent
|
||||||
(set closeEvent
|
(Vscode.window.onDidChangeVisibleTextEditors
|
||||||
(Vscode.window.onDidChangeVisibleTextEditors
|
->visibleEditors
|
||||||
->visibleEditors
|
(unless (contains visibleEditors editor)
|
||||||
(unless (contains visibleEditors editor)
|
(closeEvent.dispose)
|
||||||
(closeEvent.dispose)
|
(awaitLet [_ (showTextDocument previousEditor.document)]
|
||||||
(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)))))))))))))
|
||||||
(if editor.document.isDirty (let [error "Input editor for $prompt was closed without saving."] (warningMessage error) (reject error)) (resolve (editor.document.getText))))))))))))
|
|
||||||
|
|
||||||
// Open any folder in a fresh VSCode instance.
|
// Open any folder in a fresh VSCode instance.
|
||||||
(function openFolder [folder]
|
(function openFolder [folder]
|
||||||
|
Reference in New Issue
Block a user