diff --git a/package.json b/package.json index 0128406d7..9a8c86e79 100644 --- a/package.json +++ b/package.json @@ -323,6 +323,11 @@ "default": true, "description": "Suppress 'hidden' diagnostics (such as 'unnecessary using directives') from appearing in the editor or the Problems pane." }, + "csharp.showReferencesCodeLens": { + "type": "boolean", + "default": true, + "description": "Specifies whether the references CodeLens show be shown." + }, "omnisharp.path": { "type": [ "string", diff --git a/src/features/codeLensProvider.ts b/src/features/codeLensProvider.ts index e17602004..cccd3d6c0 100644 --- a/src/features/codeLensProvider.ts +++ b/src/features/codeLensProvider.ts @@ -13,6 +13,7 @@ import { toRange, toLocation } from '../omnisharp/typeConvertion'; import AbstractProvider from './abstractProvider'; import * as protocol from '../omnisharp/protocol'; import * as serverUtils from '../omnisharp/utils'; +import { Options } from '../omnisharp/options'; class OmniSharpCodeLens extends vscode.CodeLens { @@ -43,6 +44,12 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen }; provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable { + const options = Options.Read(); + if (!options.showReferencesCodeLens) + { + return []; + } + return serverUtils.currentFileMembersAsTree(this._server, { FileName: document.fileName }, token).then(tree => { let ret: vscode.CodeLens[] = []; tree.TopLevelTypeDefinitions.forEach(node => this._convertQuickFix(ret, document.fileName, node)); diff --git a/src/omnisharp/options.ts b/src/omnisharp/options.ts index 435ce39d2..56f4026c0 100644 --- a/src/omnisharp/options.ts +++ b/src/omnisharp/options.ts @@ -15,7 +15,8 @@ export class Options { public projectLoadTimeout?: number, public maxProjectResults?: number, public useEditorFormattingSettings?: boolean, - public useFormatting?: boolean) { } + public useFormatting?: boolean, + public showReferencesCodeLens?: boolean) { } public static Read(): Options { // Extra effort is taken below to ensure that legacy versions of options @@ -51,6 +52,17 @@ export class Options { const useFormatting = csharpConfig.get('format.enable', true); - return new Options(path, useMono, waitForDebugger, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings, useFormatting); + const showReferencesCodeLens = csharpConfig.get('showReferencesCodeLens', true); + + return new Options(path, + useMono, + waitForDebugger, + loggingLevel, + autoStart, + projectLoadTimeout, + maxProjectResults, + useEditorFormattingSettings, + useFormatting, + showReferencesCodeLens); } } \ No newline at end of file