Skip to content

Commit

Permalink
extension/src: disable code lenses when Go Companion is active
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
firelizzard18 authored and hyangah committed Nov 18, 2024
1 parent 3ec24ac commit d7a2ad5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions extension/src/goRunTestCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
})
);
Expand Down

0 comments on commit d7a2ad5

Please sign in to comment.