Skip to content

Commit

Permalink
Ensure we only start one instance of OmniSharp server
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Jun 14, 2021
1 parent 19b027b commit 126e62f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ export class OmniSharpServer {
// --- start, stop, and connect

private async _start(launchTarget: LaunchTarget, options: Options): Promise<void> {
if (this._state != ServerState.Stopped) {
this.eventStream.post(new ObservableEvents.OmnisharpServerOnServerError("Attempt to start OmniSharp server failed because another server instance is running."));
return;
}

if (launchTarget.kind === LaunchTargetKind.LiveShare) {
this.eventStream.post(new ObservableEvents.OmnisharpServerMessage("During Live Share sessions language services are provided by the Live Share server."));
Expand Down Expand Up @@ -498,6 +502,11 @@ export class OmniSharpServer {
}

public async restart(launchTarget: LaunchTarget = this._launchTarget): Promise<void> {
if (this._state == ServerState.Starting) {
this.eventStream.post(new ObservableEvents.OmnisharpServerOnServerError("Attempt to restart OmniSharp server failed because another server instance is starting."));
return;
}

if (launchTarget) {
await this.stop();
this.eventStream.post(new ObservableEvents.OmnisharpRestart());
Expand Down

0 comments on commit 126e62f

Please sign in to comment.