Port emacs find-file command

This commit is contained in:
2021-12-26 23:30:51 -07:00
parent c8c65b66fe
commit 9702037c16

View File

@@ -0,0 +1,19 @@
// Commands that kind of emulate EMACS commands
// Before you use commands in this file:
/* (loadFrom "kiss-vscode" "src/commands/EmacsPorts.kiss") */
// Open any file in VSCode, creating it if necessary
(function :Void _forceOpenFile [:String file]
(let [&mut uri (Uri.file file)]
(unless (FileSystem.exists file)
(set uri (uri.with (object scheme "untitled"))))
(awaitLet [doc (openTextDocument uri)]
(showTextDocument doc))))
/*
(registerCommand "[xf] emacs find-file" ->[&opt _] (findFile "path/to/dir"))
*/
// TODO use current file's containing folder as a default
(function :Void findFile [&opt :String dir]
(chooseFileInDir _forceOpenFile true dir))