From d7a2ad57600488d35e44ae209e6799b0a1423d70 Mon Sep 17 00:00:00 2001 From: Ethan Reesor Date: Sat, 16 Nov 2024 09:40:31 -0700 Subject: [PATCH] extension/src: disable code lenses when Go Companion is active Updates golang/vscode-go#3597 Change-Id: Ib6d6d30e7970a5b5581919fe58943346b355cf7d Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/628536 Reviewed-by: Dmitri Shuralyov Commit-Queue: Ethan Reesor kokoro-CI: kokoro Reviewed-by: Hyang-Ah Hana Kim Reviewed-by: Hongxiang Jiang --- extension/src/goRunTestCodelens.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/extension/src/goRunTestCodelens.ts b/extension/src/goRunTestCodelens.ts index 1a66241770..aa41ebd055 100644 --- a/extension/src/goRunTestCodelens.ts +++ b/extension/src/goRunTestCodelens.ts @@ -15,19 +15,26 @@ import { GoDocumentSymbolProvider } from './goDocumentSymbols'; import { getBenchmarkFunctions, getTestFunctions } from './testUtils'; import { GoExtensionContext } from './context'; import { GO_MODE } from './goMode'; +import { experiments } from './experimental'; export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider { static activate(ctx: vscode.ExtensionContext, goCtx: GoExtensionContext) { const testCodeLensProvider = new this(goCtx); + const setEnabled = () => { + const updatedGoConfig = getGoConfig(); + if (updatedGoConfig['enableCodeLens']) { + testCodeLensProvider.setEnabled( + updatedGoConfig['enableCodeLens']['runtest'] && !experiments.testExplorer + ); + } + }; + ctx.subscriptions.push(vscode.languages.registerCodeLensProvider(GO_MODE, testCodeLensProvider)); + ctx.subscriptions.push(experiments.onDidChange(() => setEnabled())); ctx.subscriptions.push( vscode.workspace.onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => { - if (!e.affectsConfiguration('go')) { - return; - } - const updatedGoConfig = getGoConfig(); - if (updatedGoConfig['enableCodeLens']) { - testCodeLensProvider.setEnabled(updatedGoConfig['enableCodeLens']['runtest']); + if (e.affectsConfiguration('go')) { + setEnabled(); } }) );