Skip to content

Commit 3114621

Browse files
committed
fixed references code lens and added ability to disable tests code lens
1 parent 38ffa15 commit 3114621

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/features/codeLensProvider.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ class OmniSharpCodeLens extends vscode.CodeLens {
2828
export default class OmniSharpCodeLensProvider extends AbstractProvider implements vscode.CodeLensProvider {
2929

3030
private _testManager: TestManager;
31+
private _options: Options;
3132

3233
constructor(server: OmniSharpServer, reporter: TelemetryReporter, testManager: TestManager)
3334
{
3435
super(server, reporter);
3536

3637
this._testManager = testManager;
38+
this._options = Options.Read();
3739
}
3840

3941
private static filteredSymbolNames: { [name: string]: boolean } = {
@@ -44,8 +46,7 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
4446
};
4547

4648
provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
47-
const options = Options.Read();
48-
if (!options.showReferencesCodeLens)
49+
if (!this._options.showReferencesCodeLens && !this._options.showTestsCodeLens)
4950
{
5051
return [];
5152
}
@@ -64,13 +65,17 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
6465
}
6566

6667
let lens = new OmniSharpCodeLens(fileName, toRange(node.Location));
67-
bucket.push(lens);
68+
if (this._options.showReferencesCodeLens) {
69+
bucket.push(lens);
70+
}
6871

6972
for (let child of node.ChildNodes) {
7073
this._convertQuickFix(bucket, fileName, child);
7174
}
7275

73-
this._updateCodeLensForTest(bucket, fileName, node);
76+
if (this._options.showTestsCodeLens) {
77+
this._updateCodeLensForTest(bucket, fileName, node);
78+
}
7479
}
7580

7681
resolveCodeLens(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Thenable<vscode.CodeLens> {

src/omnisharp/options.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export class Options {
1616
public maxProjectResults?: number,
1717
public useEditorFormattingSettings?: boolean,
1818
public useFormatting?: boolean,
19-
public showReferencesCodeLens?: boolean) { }
19+
public showReferencesCodeLens?: boolean,
20+
public showTestsCodeLens?: boolean) { }
2021

2122
public static Read(): Options {
2223
// Extra effort is taken below to ensure that legacy versions of options
@@ -53,6 +54,7 @@ export class Options {
5354
const useFormatting = csharpConfig.get<boolean>('format.enable', true);
5455

5556
const showReferencesCodeLens = csharpConfig.get<boolean>('showReferencesCodeLens', true);
57+
const showTestsCodeLens = csharpConfig.get<boolean>('showTestsCodeLens', true);
5658

5759
return new Options(path,
5860
useMono,
@@ -63,6 +65,7 @@ export class Options {
6365
maxProjectResults,
6466
useEditorFormattingSettings,
6567
useFormatting,
66-
showReferencesCodeLens);
68+
showReferencesCodeLens,
69+
showTestsCodeLens);
6770
}
6871
}

0 commit comments

Comments
 (0)