Skip to content

Commit

Permalink
feat: allow disabling shutdownGracefully
Browse files Browse the repository at this point in the history
Setting it to false allows quick killing of the servers instead of
waiting

Co-Authored-By: Alex Butler <[email protected]>
  • Loading branch information
aminya and alexheretic committed Jun 13, 2021
1 parent 4200aa2 commit 14bec25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/auto-languageclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
*
Expand Down
5 changes: 3 additions & 2 deletions lib/server-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 14bec25

Please sign in to comment.