Make sure we never cancel a request to just one of the ts servers

Fixes #76143
This commit is contained in:
Matt Bierner
2019-06-25 16:22:13 -07:00
parent 53f050c0f3
commit 9670060267

View File

@@ -357,8 +357,34 @@ export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServ
return this.syntaxServer.executeImpl(command, args, executeInfo);
} else if (SyntaxRoutingTsServer.sharedCommands.has(command)) {
// Dispatch to both server but only return from syntax one
this.semanticServer.executeImpl(command, args, executeInfo);
return this.syntaxServer.executeImpl(command, args, executeInfo);
// Also make sure we never cancel requests to just one server
let hasCompletedSyntax = false;
let hasCompletedSemantic = false;
let token: vscode.CancellationToken | undefined = undefined;
if (executeInfo.token) {
const source = new vscode.CancellationTokenSource();
executeInfo.token.onCancellationRequested(() => {
if (hasCompletedSyntax && !hasCompletedSemantic || hasCompletedSemantic && !hasCompletedSyntax) {
// Don't cancel.
// One of the servers completed this request so we don't want to leave the other
// in a different state
return;
}
source.cancel();
});
token = source.token;
}
const semanticRequest = this.semanticServer.executeImpl(command, args, { ...executeInfo, token });
if (semanticRequest) {
semanticRequest.finally(() => { hasCompletedSemantic = true; });
}
const syntaxRequest = this.syntaxServer.executeImpl(command, args, { ...executeInfo, token });
if (syntaxRequest) {
syntaxRequest.finally(() => { hasCompletedSyntax = true; });
}
return syntaxRequest;
} else {
return this.semanticServer.executeImpl(command, args, executeInfo);
}