Skip to content

Commit 38ffa15

Browse files
Merge pull request #1781 from rchande/codeLensOption
Add an option to disable the references CodeLens
2 parents 2a0d82e + 1d63100 commit 38ffa15

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@
323323
"default": true,
324324
"description": "Suppress 'hidden' diagnostics (such as 'unnecessary using directives') from appearing in the editor or the Problems pane."
325325
},
326+
"csharp.showReferencesCodeLens": {
327+
"type": "boolean",
328+
"default": true,
329+
"description": "Specifies whether the references CodeLens show be shown."
330+
},
326331
"omnisharp.path": {
327332
"type": [
328333
"string",

src/features/codeLensProvider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { toRange, toLocation } from '../omnisharp/typeConvertion';
1313
import AbstractProvider from './abstractProvider';
1414
import * as protocol from '../omnisharp/protocol';
1515
import * as serverUtils from '../omnisharp/utils';
16+
import { Options } from '../omnisharp/options';
1617

1718
class OmniSharpCodeLens extends vscode.CodeLens {
1819

@@ -43,6 +44,12 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
4344
};
4445

4546
provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
47+
const options = Options.Read();
48+
if (!options.showReferencesCodeLens)
49+
{
50+
return [];
51+
}
52+
4653
return serverUtils.currentFileMembersAsTree(this._server, { FileName: document.fileName }, token).then(tree => {
4754
let ret: vscode.CodeLens[] = [];
4855
tree.TopLevelTypeDefinitions.forEach(node => this._convertQuickFix(ret, document.fileName, node));

src/omnisharp/options.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export class Options {
1515
public projectLoadTimeout?: number,
1616
public maxProjectResults?: number,
1717
public useEditorFormattingSettings?: boolean,
18-
public useFormatting?: boolean) { }
18+
public useFormatting?: boolean,
19+
public showReferencesCodeLens?: boolean) { }
1920

2021
public static Read(): Options {
2122
// Extra effort is taken below to ensure that legacy versions of options
@@ -51,6 +52,17 @@ export class Options {
5152

5253
const useFormatting = csharpConfig.get<boolean>('format.enable', true);
5354

54-
return new Options(path, useMono, waitForDebugger, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings, useFormatting);
55+
const showReferencesCodeLens = csharpConfig.get<boolean>('showReferencesCodeLens', true);
56+
57+
return new Options(path,
58+
useMono,
59+
waitForDebugger,
60+
loggingLevel,
61+
autoStart,
62+
projectLoadTimeout,
63+
maxProjectResults,
64+
useEditorFormattingSettings,
65+
useFormatting,
66+
showReferencesCodeLens);
5567
}
5668
}

0 commit comments

Comments
 (0)