@@ -49,34 +49,42 @@ async function getPathIfAvailable(path: string): Promise<string | null> {
49
49
return ( await pathExists ( path ) ) ? path : null
50
50
}
51
51
52
+ async function getFirstPathIfAvailable (
53
+ possiblePaths : string [ ]
54
+ ) : Promise < string | null > {
55
+ for ( const possiblePath of possiblePaths ) {
56
+ const path = await getPathIfAvailable ( possiblePath )
57
+ if ( path ) {
58
+ return path
59
+ }
60
+ }
61
+ return null
62
+ }
63
+
52
64
async function getEditorPath ( editor : ExternalEditor ) : Promise < string | null > {
53
65
switch ( editor ) {
54
66
case ExternalEditor . Atom :
55
67
return getPathIfAvailable ( '/usr/bin/atom' )
56
68
case ExternalEditor . VSCode :
57
69
return getPathIfAvailable ( '/usr/bin/code' )
58
70
case ExternalEditor . VSCodeInsiders :
59
- return getPathIfAvailable ( '/usr/bin/code-insiders' )
71
+ return getFirstPathIfAvailable ( [
72
+ '/snap/bin/code-insiders' ,
73
+ '/usr/bin/code-insiders' ,
74
+ ] )
60
75
case ExternalEditor . VSCodium :
61
76
return getPathIfAvailable ( '/usr/bin/codium' )
62
77
case ExternalEditor . SublimeText :
63
78
return getPathIfAvailable ( '/usr/bin/subl' )
64
79
case ExternalEditor . Typora :
65
80
return getPathIfAvailable ( '/usr/bin/typora' )
66
81
case ExternalEditor . SlickEdit :
67
- const possiblePaths = [
82
+ return getFirstPathIfAvailable ( [
68
83
'/opt/slickedit-pro2018/bin/vs' ,
69
84
'/opt/slickedit-pro2017/bin/vs' ,
70
85
'/opt/slickedit-pro2016/bin/vs' ,
71
86
'/opt/slickedit-pro2015/bin/vs' ,
72
- ]
73
- for ( const possiblePath of possiblePaths ) {
74
- const slickeditPath = await getPathIfAvailable ( possiblePath )
75
- if ( slickeditPath ) {
76
- return slickeditPath
77
- }
78
- }
79
- return null
87
+ ] )
80
88
default :
81
89
return assertNever ( editor , `Unknown editor: ${ editor } ` )
82
90
}
0 commit comments