Skip to content

Commit 833b28a

Browse files
author
Ravi Chande
committed
Add an option to disable the references CodeLens
1 parent 2a0d82e commit 833b28a

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@
373373
"type": "boolean",
374374
"default": true,
375375
"description": "Specifes whether OmniSharp should use VS Code editor settings for C# code formatting (use of tabs, indentation size)."
376+
},
377+
"omnisharp.showReferencesCodeLens": {
378+
"type": "boolean",
379+
"default": true,
380+
"description": "Specifies whether Omnisharp should show the references CodeLens"
376381
}
377382
}
378383
},

src/features/codeLensProvider.ts

Lines changed: 8 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,13 @@ 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+
let arr: vscode.CodeLens[] = [];
51+
return arr;
52+
}
53+
4654
return serverUtils.currentFileMembersAsTree(this._server, { FileName: document.fileName }, token).then(tree => {
4755
let ret: vscode.CodeLens[] = [];
4856
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 = omnisharpConfig.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)