From e1802f49660a30df702c160f4ed001ccacdb33e3 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 8 Aug 2017 10:49:49 -0700 Subject: [PATCH] MultistepOperation: Don't need 'completed', just use `requestId === undefined` (#17173) * MultistepOperation: Don't need 'completed', just use `requestId === undefined` * Check for `requestId !== undefined` --- src/server/session.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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);