From 13d165cd83af03ee5e88860112b5b7fc93285aca Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 29 Dec 2022 10:06:46 -0800 Subject: [PATCH] perf(extension): Ensure Angular code actions are only retrieved in Angular contexts (#1842) This change extends the short-circuit logic that has been enabled for other features to the code actions as well. Original issue was #1176 New performance issues have been reported recently (#1840), likely due to the code fixes for auto imports. --- client/src/client.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/client.ts b/client/src/client.ts index 06bfc60f9a..b2c1cb65fc 100644 --- a/client/src/client.ts +++ b/client/src/client.ts @@ -60,6 +60,15 @@ export class AngularLanguageClient implements vscode.Disposable { revealOutputChannelOn: lsp.RevealOutputChannelOn.Never, outputChannel: this.outputChannel, middleware: { + provideCodeActions: async ( + document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, + token: vscode.CancellationToken, next: lsp.ProvideCodeActionsSignature) => { + if (await this.isInAngularProject(document) && + isInsideInlineTemplateRegion(document, range.start) && + isInsideInlineTemplateRegion(document, range.end)) { + return next(document, range, context, token); + } + }, prepareRename: async ( document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, next: lsp.PrepareRenameSignature) => {