Skip to content

Commit

Permalink
fix #1314 allow for simultaneous language features (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Oct 16, 2017
1 parent abdcf20 commit 792b022
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 792b022

Please sign in to comment.