Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Fixes #964 Combine settings to enable/disable different codelens
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed May 5, 2017
1 parent 352435a commit d3c8957
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,25 @@
"default": false,
"description": "If false, the import statements will be excluded while using the Go to Symbol in File feature"
},
"go.referencesCodeLens.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable references CodeLens"
"go.enableCodeLens": {
"type": "object",
"properties": {
"references": {
"type": "boolean",
"default": false,
"description": "If true, enables the references code lens. Uses guru. Recalculates when there is change to the document followed by scrolling."
},
"runtest": {
"type": "boolean",
"default": true,
"description": "If true, enables code lens for running and debugging tests"
}
},
"default": {
"references": false,
"runtest": true
},
"description": "Feature level setting to enable/disable code lens for references and run/debug tests"
},
"go.addTags": {
"type": "object",
Expand Down
3 changes: 2 additions & 1 deletion src/goCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ReferencesCodeLens extends CodeLens {

export class GoCodeLensProvider implements CodeLensProvider {
public provideCodeLenses(document: TextDocument, token: CancellationToken): CodeLens[] | Thenable<CodeLens[]> {
let codelensEnabled = vscode.workspace.getConfiguration('go').get('referencesCodeLens.enabled');
let codeLensConfig = vscode.workspace.getConfiguration('go').get('enableCodeLens');
let codelensEnabled = codeLensConfig ? codeLensConfig['references'] : false;
if (!codelensEnabled) {
return Promise.resolve([]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function sendTelemetryEventForConfig(goConfig: vscode.WorkspaceConfiguration) {
removeTags: JSON.stringify(goConfig['removeTags']),
editorContextMenuCommands: JSON.stringify(goConfig['editorContextMenuCommands']),
liveErrors: JSON.stringify(goConfig['liveErrors']),
referencesCodeLens: goConfig['referencesCodeLens'] && goConfig['referencesCodeLens']['enabled'] + '',
codeLens: JSON.stringify(goConfig['enableCodeLens']),
coverageOptions: goConfig['coverageOptions']
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/goRunTestCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class GoRunTestCodeLensProvider implements CodeLensProvider {
};

public provideCodeLenses(document: TextDocument, token: CancellationToken): CodeLens[] | Thenable<CodeLens[]> {
if (!document.fileName.endsWith('_test.go')) {
let codeLensConfig = vscode.workspace.getConfiguration('go').get('enableCodeLens');
let codelensEnabled = codeLensConfig ? codeLensConfig['runtest'] : false;
if (!codelensEnabled || !document.fileName.endsWith('_test.go')) {
return;
}

Expand Down

0 comments on commit d3c8957

Please sign in to comment.