Skip interrupting geterr in automatic cases (#215389)

Quick fixes already don't interrupt `geterr` requests so this likely won't slow down the automatic lightbulb
This commit is contained in:
Matt Bierner 2024-06-12 14:29:41 -07:00 committed by GitHub
parent b7e5750fa9
commit 94274c47b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -541,11 +541,12 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
return undefined;
}
const response = await this.client.interruptGetErr(() => {
const response = await this.interruptGetErrIfNeeded(context, () => {
const file = this.client.toOpenTsFilePath(document);
if (!file) {
return undefined;
}
this.formattingOptionsManager.ensureConfigurationForDocument(document, token);
const args: Proto.GetApplicableRefactorsRequestArgs = {
@ -595,6 +596,17 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
return this.pruneInvalidActions(this.appendInvalidActions(actions), context.only, /* numberOfInvalid = */ 5);
}
private interruptGetErrIfNeeded<R>(context: vscode.CodeActionContext, f: () => R): R {
// Only interrupt diagnostics computation when code actions are explicitly
// (such as using the refactor command or a keybinding). This is a clear
// user action so we want to return results as quickly as possible.
if (context.triggerKind === vscode.CodeActionTriggerKind.Invoke) {
return this.client.interruptGetErr(f);
} else {
return f();
}
}
public async resolveCodeAction(
codeAction: TsCodeAction,
token: vscode.CancellationToken,