From 14bec2586e85252e418b26d55cdd2c498cbabf58 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 11 Jun 2021 19:42:11 -0500 Subject: [PATCH] feat: allow disabling shutdownGracefully Setting it to false allows quick killing of the servers instead of waiting Co-Authored-By: Alex Butler --- lib/auto-languageclient.ts | 9 ++++++++- lib/server-manager.ts | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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() }