diff --git a/src/server/index.ts b/src/server/index.ts index 160bce2..6744848 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -100,14 +100,14 @@ export default class TsserverService implements IServiceProvider { } public async start(): Promise { - if (!this.enable) return + if (!this.enable || this._state == ServiceStat.Starting) return + this._state = ServiceStat.Starting if (this.clientHost) { let client = this.clientHost.serviceClient client.restartTsServer() return } - let tscPath = await workspace.nvim.getVar('Tsserver_path') as string - this._state = ServiceStat.Starting + let tscPath = await workspace.nvim.getVar('Tsserver_path') as string | null this.clientHost = new TypeScriptServiceClientHost(this.descriptions, this.pluginManager, tscPath) let client = this.clientHost.serviceClient await new Promise(resolve => { @@ -132,7 +132,7 @@ export default class TsserverService implements IServiceProvider { if (!this.clientHost) return let client = this.clientHost.serviceClient await client.stop() - this.clientHost.dispose() + this.clientHost?.dispose() this.clientHost = null this._state = ServiceStat.Stopped } diff --git a/src/server/typescriptServiceClientHost.ts b/src/server/typescriptServiceClientHost.ts index 4113e09..dd44d49 100644 --- a/src/server/typescriptServiceClientHost.ts +++ b/src/server/typescriptServiceClientHost.ts @@ -38,7 +38,7 @@ export default class TypeScriptServiceClientHost implements Disposable { private readonly fileConfigurationManager: FileConfigurationManager private reportStyleCheckAsWarnings = true - constructor(descriptions: LanguageDescription[], pluginManager: PluginManager, tscPath: string | undefined) { + constructor(descriptions: LanguageDescription[], pluginManager: PluginManager, tscPath: string | null) { let timer: NodeJS.Timer const handleProjectChange = () => { if (timer) clearTimeout(timer)