-
Notifications
You must be signed in to change notification settings - Fork 370
Description
Over in the PowerShell extension I was finally able to update to the latest version of this library, and it is much improved, thank you so much. Thing is, we already have our own restart experience. For architectural reasons, the extension's LSP server is also an extension-owned terminal. This means that users sometimes close the terminal, and then that shuts down the language server. So for a long time we've already thrown an error message that has to be very clearly worded that the terminal is a requirement for the server (and so for LSP features like completions etc.), and give a Yes/No prompt to restart it. This works great, but means that we use DoNotRestart for our CloseAction.
However, in the update this library now throws an error message:
vscode-languageserver-node/client/src/common/client.ts
Lines 1469 to 1486 in 3b6f361
| if (handlerResult.action === CloseAction.DoNotRestart) { | |
| this.error(handlerResult.message ?? 'Connection to server got closed. Server will not be restarted.', undefined, 'force'); | |
| this.cleanUp('stop'); | |
| if (this.$state === ClientState.Starting) { | |
| this.$state = ClientState.StartFailed; | |
| } else { | |
| this.$state = ClientState.Stopped; | |
| } | |
| this._onStop = Promise.resolve(); | |
| this._onStart = undefined; | |
| } else if (handlerResult.action === CloseAction.Restart) { | |
| this.info(handlerResult.message ?? 'Connection to server got closed. Server will restart.'); | |
| this.cleanUp('restart'); | |
| this.$state = ClientState.Initial; | |
| this._onStop = Promise.resolve(); | |
| this._onStart = undefined; | |
| this.start().catch((error) => this.error(`Restarting server failed`, error, 'force')); | |
| } |
and I can't suppress it! Which annoyingly to our users leads to two error messages, and we'd really like to keep ours as it's an interactive prompt asking if the user wants to restart the server.
I would like for you to consider implementing one of two options:
- Add a
PromptForRestartoption, that we would then move to instead ofDoNotRestartand has a similar Yes/No option for the user, and then we just feed our existing message as customization - Add a way to suppress the error/info message thrown by the library
For now, in PowerShell/vscode-powershell#4141 I've customized the message in our CloseAction to refer to the prompt, and so the experience looks like:
