Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/client/providers/jediProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,29 +677,29 @@ export interface IHoverItem {

export class JediProxyHandler<R extends ICommandResult> {
private jediProxy: JediProxy;
private cancellationTokenSource: vscode.CancellationTokenSource;
private commandCancellationTokenSources: Map<CommandType, vscode.CancellationTokenSource>;

public get JediProxy(): JediProxy {
return this.jediProxy;
}

public constructor(context: vscode.ExtensionContext, jediProxy: JediProxy = null) {
this.jediProxy = jediProxy ? jediProxy : new JediProxy(context);
this.commandCancellationTokenSources = new Map<CommandType, vscode.CancellationTokenSource>();
}

public sendCommand(cmd: ICommand<R>, token?: vscode.CancellationToken): Promise<R> {
var executionCmd = <IExecutionCommand<R>>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<R>(executionCmd)
.catch(reason => {
Expand Down