Skip to content

Consider allowing suppression of CloseAction error/info message #1057

@andyleejordan

Description

@andyleejordan

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:

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 PromptForRestart option, that we would then move to instead of DoNotRestart and 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:

Screen Shot 2022-08-17 at 5 54 05 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues identified as good community contribution opportunities

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions