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.VSCode" find-native-bundle [
25 "Contents/MacOS/Electron" append-path
30 ERROR: can't-find-visual-studio-code ;
32 M: linux find-visual-studio-code-invocation
36 [ home "VSCode-linux-x64/Code" append-path ]
37 [ "/usr/share/code/code" ]
38 } [ dup exists? [ drop f ] unless ] map-compose 0|| ;
40 M: windows find-visual-studio-code-invocation
42 [ { "Microsoft VS Code" } "code.exe" find-in-applications ]
46 M: visual-studio-code editor-command ( file line -- command )
48 visual-studio-code-invocation
49 [ , ] [ can't-find-visual-studio-code ] if*
51 number>string ":" glue ,