refactor out file-choosing functionality of osOpenFileInDir
This commit is contained in:
@@ -81,6 +81,16 @@
|
||||
(awaitLet [,v (quickPickMap ,options)]
|
||||
,@body)))
|
||||
|
||||
(function :Void chooseFileInDir [:String->Void openFile :Bool allowNew &opt :String dir]
|
||||
(withValueOrInputBox dir
|
||||
(awaitLet [dirOrFile (quickPick (sys.FileSystem.readDirectory dir))]
|
||||
(let [dirOrFile (joinPath dir dirOrFile)]
|
||||
(cond
|
||||
((sys.FileSystem.isDirectory dirOrFile)
|
||||
(chooseFileInDir openFile allowNew dirOrFile))
|
||||
(true
|
||||
(openFile dirOrFile)))))))
|
||||
|
||||
// This has to be a macro so it can return from tryLoadConfig
|
||||
(defMacro trySpawnSync [command args options onError]
|
||||
`(let [command ,command
|
||||
|
@@ -24,11 +24,4 @@
|
||||
(registerCommand "desired name with [a]ny [b]indings" ->[&opt _] (osOpenFileInDir "path/to/dir"))
|
||||
*/
|
||||
(function :Void osOpenFileInDir [&opt :String dir]
|
||||
(withValueOrInputBox dir
|
||||
(awaitLet [dirOrFile (quickPick (sys.FileSystem.readDirectory dir))]
|
||||
(let [dirOrFile (joinPath dir dirOrFile)]
|
||||
(cond
|
||||
((sys.FileSystem.isDirectory dirOrFile)
|
||||
(osOpenFileInDir dirOrFile))
|
||||
(true
|
||||
(osOpenFile dirOrFile)))))))
|
||||
(chooseFileInDir osOpenFile false dir))
|
Reference in New Issue
Block a user