mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Try to interupt getErr request for user opetions
This commit is contained in:
parent
1cbd30833b
commit
d96cf918b7
|
@ -256,6 +256,7 @@ export default class BufferSyncSupport extends Disposable {
|
|||
if (!syncedBuffer) {
|
||||
return;
|
||||
}
|
||||
this.pendingDiagnostics.delete(resource);
|
||||
this.syncedBuffers.delete(resource);
|
||||
syncedBuffer.close();
|
||||
if (!fs.existsSync(resource.fsPath)) {
|
||||
|
@ -264,6 +265,19 @@ export default class BufferSyncSupport extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
public interuptGetErr<R>(f: () => R): R {
|
||||
console.log('try inter');
|
||||
if (!this.pendingGetErr) {
|
||||
return f();
|
||||
}
|
||||
|
||||
this.pendingGetErr.cancel();
|
||||
this.pendingGetErr = undefined;
|
||||
const result = f();
|
||||
this.triggerDiagnostics();
|
||||
return result;
|
||||
}
|
||||
|
||||
private onDidCloseTextDocument(document: vscode.TextDocument): void {
|
||||
this.closeResource(document.uri);
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
|||
return null;
|
||||
}
|
||||
|
||||
await this.fileConfigurationManager.ensureConfigurationForDocument(document, token);
|
||||
await this.client.interuptGetErr(() => this.fileConfigurationManager.ensureConfigurationForDocument(document, token));
|
||||
|
||||
const args: Proto.CompletionsRequestArgs = {
|
||||
...typeConverters.Position.toFileLocationRequestArgs(file, position),
|
||||
|
@ -313,19 +313,18 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
|||
triggerCharacter: context.triggerCharacter as Proto.CompletionsTriggerCharacter
|
||||
};
|
||||
|
||||
|
||||
let enableCommitCharacters = true;
|
||||
let msg: ReadonlyArray<Proto.CompletionEntry> | undefined = undefined;
|
||||
try {
|
||||
if (this.client.apiVersion.gte(API.v300)) {
|
||||
const { body } = await this.client.execute('completionInfo', args, token);
|
||||
const { body } = await this.client.interuptGetErr(() => this.client.execute('completionInfo', args, token));
|
||||
if (!body) {
|
||||
return null;
|
||||
}
|
||||
enableCommitCharacters = !body.isNewIdentifierLocation;
|
||||
msg = body.entries;
|
||||
} else {
|
||||
const { body } = await this.client.execute('completions', args, token);
|
||||
const { body } = await this.client.interuptGetErr(() => this.client.execute('completions', args, token));
|
||||
if (!body) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ class TypeScriptHoverProvider implements vscode.HoverProvider {
|
|||
if (!filepath) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const args = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
|
||||
try {
|
||||
const { body } = await this.client.execute('quickinfo', args, token);
|
||||
const { body } = await this.client.interuptGetErr(() => this.client.execute('quickinfo', args, token));
|
||||
if (body) {
|
||||
return new vscode.Hover(
|
||||
TypeScriptHoverProvider.getContents(body),
|
||||
|
|
|
@ -91,4 +91,9 @@ export interface ITypeScriptServiceClient {
|
|||
executeWithoutWaitingForResponse(command: 'reloadProjects', args: null): void;
|
||||
|
||||
executeAsync(command: 'geterr', args: Proto.GeterrRequestArgs, token: vscode.CancellationToken): Promise<any>;
|
||||
|
||||
/**
|
||||
* Cancel on going geterr requests and re-queue them after `f` has been evaluated.
|
||||
*/
|
||||
interuptGetErr<R>(f: () => R): R;
|
||||
}
|
|
@ -738,6 +738,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
return result;
|
||||
}
|
||||
|
||||
public interuptGetErr<R>(f: () => R): R {
|
||||
return this.bufferSyncSupport.interuptGetErr(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a `errorText` from a tsserver request indicating failure in handling a request,
|
||||
* prepares a payload for telemetry-logging.
|
||||
|
|
Loading…
Reference in a new issue