Skip to content

feat: allow disabling shutdownGracefully #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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