Skip to content

Commit d7a2ad5

Browse files
firelizzard18hyangah
authored andcommitted
extension/src: disable code lenses when Go Companion is active
Updates #3597 Change-Id: Ib6d6d30e7970a5b5581919fe58943346b355cf7d Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/628536 Reviewed-by: Dmitri Shuralyov <[email protected]> Commit-Queue: Ethan Reesor <[email protected]> kokoro-CI: kokoro <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Hongxiang Jiang <[email protected]>
1 parent 3ec24ac commit d7a2ad5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

extension/src/goRunTestCodelens.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ import { GoDocumentSymbolProvider } from './goDocumentSymbols';
1515
import { getBenchmarkFunctions, getTestFunctions } from './testUtils';
1616
import { GoExtensionContext } from './context';
1717
import { GO_MODE } from './goMode';
18+
import { experiments } from './experimental';
1819

1920
export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider {
2021
static activate(ctx: vscode.ExtensionContext, goCtx: GoExtensionContext) {
2122
const testCodeLensProvider = new this(goCtx);
23+
const setEnabled = () => {
24+
const updatedGoConfig = getGoConfig();
25+
if (updatedGoConfig['enableCodeLens']) {
26+
testCodeLensProvider.setEnabled(
27+
updatedGoConfig['enableCodeLens']['runtest'] && !experiments.testExplorer
28+
);
29+
}
30+
};
31+
2232
ctx.subscriptions.push(vscode.languages.registerCodeLensProvider(GO_MODE, testCodeLensProvider));
33+
ctx.subscriptions.push(experiments.onDidChange(() => setEnabled()));
2334
ctx.subscriptions.push(
2435
vscode.workspace.onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => {
25-
if (!e.affectsConfiguration('go')) {
26-
return;
27-
}
28-
const updatedGoConfig = getGoConfig();
29-
if (updatedGoConfig['enableCodeLens']) {
30-
testCodeLensProvider.setEnabled(updatedGoConfig['enableCodeLens']['runtest']);
36+
if (e.affectsConfiguration('go')) {
37+
setEnabled();
3138
}
3239
})
3340
);

0 commit comments

Comments
 (0)