@@ -44,6 +44,8 @@ class TypeScriptLanguageClient extends AutoLanguageClient {
44
44
45
45
shouldStartForEditor ( editor ) {
46
46
const projectPath = this . getProjectPath ( editor . getURI ( ) || '' ) ;
47
+ if ( ! projectPath ) return false
48
+
47
49
if ( atom . config . get ( 'ide-typescript.ignoreFlow' ) === true ) {
48
50
const flowConfigPath = path . join ( projectPath , '.flowconfig' )
49
51
if ( fs . existsSync ( flowConfigPath ) ) return false
@@ -79,12 +81,20 @@ class TypeScriptLanguageClient extends AutoLanguageClient {
79
81
}
80
82
81
83
getServerPath ( projectPath ) {
82
- const tsSpecifiedPath = atom . config . get ( 'ide-typescript.typeScriptServer.path' )
83
- const localPath = path . resolve ( projectPath , tsSpecifiedPath )
84
- if ( fs . existsSync ( localPath ) ) {
85
- return localPath
84
+ const relativePathSpecifiedByUser = atom . config . get ( 'ide-typescript.typeScriptServer.path' )
85
+ const relativePathDefault = 'node_modules/typescript/lib/tsserver.js'
86
+ const absPathLocal = path . resolve ( projectPath , relativePathSpecifiedByUser )
87
+ const absPathGlobal = path . resolve ( __dirname , '..' , relativePathSpecifiedByUser )
88
+ const absPathGlobalDefault = path . resolve ( __dirname , '..' , relativePathDefault )
89
+
90
+ if ( fs . existsSync ( absPathLocal ) ) {
91
+ return absPathLocal
92
+ }
93
+ if ( fs . existsSync ( absPathGlobal ) ) {
94
+ return absPathGlobal
86
95
}
87
- return path . resolve ( __dirname , '..' , tsSpecifiedPath )
96
+
97
+ return absPathGlobalDefault
88
98
}
89
99
90
100
createTimeoutPromise ( milliseconds , cancelPromise ) {
0 commit comments