diff --git a/src/server/session.ts b/src/server/session.ts index 8fa580d7225..5c9d210939c 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -163,26 +163,22 @@ namespace ts.server { * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. */ class MultistepOperation implements NextStep { - private requestId: number; + private requestId: number | undefined; private timerHandle: any; - private immediateId: any; - private completed = true; + private immediateId: number | undefined; constructor(private readonly operationHost: MultistepOperationHost) {} public startNew(action: (next: NextStep) => void) { this.complete(); this.requestId = this.operationHost.getCurrentRequestId(); - this.completed = false; this.executeAction(action); } private complete() { - if (!this.completed) { - if (this.requestId) { - this.operationHost.sendRequestCompletedEvent(this.requestId); - } - this.completed = true; + if (this.requestId !== undefined) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + this.requestId = undefined; } this.setTimerHandle(undefined); this.setImmediateId(undefined);