1 ! Copyright (C) 2015 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators.short-circuit editors
4 generalizations io.files io.pathnames io.standard-paths kernel
5 make math.parser memoize namespaces sequences system tools.which ;
6 IN: editors.visual-studio-code
8 ! Command line arguments
9 ! https://code.visualstudio.com/docs/editor/command-line
11 SINGLETON: visual-studio-code
12 visual-studio-code editor-class set-global
14 HOOK: find-visual-studio-code-invocation os ( -- array )
16 : visual-studio-code-invocation ( -- array )
18 [ \ visual-studio-code-invocation get ]
19 [ find-visual-studio-code-invocation ]
23 M: macosx find-visual-studio-code-invocation
24 { "com.microsoft.VSCodeInsiders" "com.microsoft.VSCode" }
25 [ find-native-bundle ] map-find drop [
26 "Contents/MacOS/Electron" append-path
31 ERROR: can't-find-visual-studio-code ;
33 M: linux find-visual-studio-code-invocation
35 [ "code-insiders" which ]
38 [ home "VSCode-linux-x64/Code" append-path ]
39 [ "/usr/share/code/code" ]
40 } [ dup exists? [ drop f ] unless ] map-compose 0|| ;
42 M: windows find-visual-studio-code-invocation
44 [ { "Microsoft VS Code Insiders" } "code-insiders.cmd" find-in-applications ]
48 M: visual-studio-code editor-command
50 visual-studio-code-invocation
51 [ , ] [ can't-find-visual-studio-code ] if*
53 number>string ":" glue ,