diff --git a/lib/auto-languageclient.ts b/lib/auto-languageclient.ts index 3d2e4139..0d687c06 100644 --- a/lib/auto-languageclient.ts +++ b/lib/auto-languageclient.ts @@ -315,7 +315,8 @@ export default class AutoLanguageClient { (filepath) => this.filterChangeWatchedFiles(filepath), this.reportBusyWhile, this.getServerName(), - this.determineProjectPath + this.determineProjectPath, + this.shutdownGracefully ) this._serverManager.startListening() process.on("exit", () => this.exitCleanup.bind(this)) @@ -988,6 +989,12 @@ export default class AutoLanguageClient { return true } + /** + * If this is set to `true` (the default value), the servers will shut down gracefully. If it is set to `false`, the + * servers will be killed without awaiting shutdown response. + */ + protected shutdownGracefully: boolean = true + /** * Called on language server stderr output. * diff --git a/lib/server-manager.ts b/lib/server-manager.ts index 289f92d2..eee82ddc 100644 --- a/lib/server-manager.ts +++ b/lib/server-manager.ts @@ -50,7 +50,8 @@ export class ServerManager { private _changeWatchedFileFilter: (filePath: string) => boolean, private _reportBusyWhile: ReportBusyWhile, private _languageServerName: string, - private _determineProjectPath: (textEditor: TextEditor) => string | null + private _determineProjectPath: (textEditor: TextEditor) => string | null, + private shutdownGracefully: boolean ) { this.updateNormalizedProjectPaths() } @@ -212,7 +213,7 @@ export class ServerManager { this._activeServers.splice(this._activeServers.indexOf(server), 1) this._stoppingServers.push(server) server.disposable.dispose() - if (server.connection.isConnected) { + if (this.shutdownGracefully && server.connection.isConnected) { await server.connection.shutdown() }