Allow manually restarting TS Server even if it has crashed too many times

Currently if the server crashes too many times, the user has to restart VS Code. It's possible the user could fix something (such as a bad plugin) and then run this command to just restart the server without needing to restart the entire editor
This commit is contained in:
Matt Bierner
2022-03-08 18:48:31 -08:00
parent 886ab06860
commit 9d41c706c6
2 changed files with 9 additions and 2 deletions

View File

@@ -15,6 +15,6 @@ export class RestartTsServerCommand implements Command {
) { }
public execute() {
this.lazyClientHost.value.serviceClient.restartTsServer();
this.lazyClientHost.value.serviceClient.restartTsServer(true);
}
}

View File

@@ -280,13 +280,20 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.loadingIndicator.reset();
}
public restartTsServer(): void {
public restartTsServer(fromUserAction = false): void {
if (this.serverState.type === ServerState.Type.Running) {
this.info('Killing TS Server');
this.isRestarting = true;
this.serverState.server.kill();
}
if (fromUserAction) {
// Reset crash trackers
this.hasServerFatallyCrashedTooManyTimes = false;
this.numberRestarts = 0;
this.lastStart = Date.now();
}
this.serverState = this.startService(true);
}