diff --git a/src/client/providers/jediProxy.ts b/src/client/providers/jediProxy.ts index 5b9220dfb223..776a18bd41d4 100644 --- a/src/client/providers/jediProxy.ts +++ b/src/client/providers/jediProxy.ts @@ -677,7 +677,7 @@ export interface IHoverItem { export class JediProxyHandler { private jediProxy: JediProxy; - private cancellationTokenSource: vscode.CancellationTokenSource; + private commandCancellationTokenSources: Map; public get JediProxy(): JediProxy { return this.jediProxy; @@ -685,21 +685,21 @@ export class JediProxyHandler { public constructor(context: vscode.ExtensionContext, jediProxy: JediProxy = null) { this.jediProxy = jediProxy ? jediProxy : new JediProxy(context); + this.commandCancellationTokenSources = new Map(); } public sendCommand(cmd: ICommand, token?: vscode.CancellationToken): Promise { var executionCmd = >cmd; executionCmd.id = executionCmd.id || this.jediProxy.getNextCommandId(); - if (this.cancellationTokenSource) { - try { - this.cancellationTokenSource.cancel(); - } - catch (ex) { } + if (this.commandCancellationTokenSources.has(cmd.command)) { + const cancellation = this.commandCancellationTokenSources.get(cmd.command); + cancellation.cancel(); } - this.cancellationTokenSource = new vscode.CancellationTokenSource(); - executionCmd.token = this.cancellationTokenSource.token; + const cancellation = new vscode.CancellationTokenSource(); + this.commandCancellationTokenSources.set(cmd.command, cancellation); + executionCmd.token = cancellation.token; return this.jediProxy.sendCommand(executionCmd) .catch(reason => {