Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable the references CodeLens #1781

Merged
merged 2 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@
"type": "boolean",
"default": true,
"description": "Specifes whether OmniSharp should use VS Code editor settings for C# code formatting (use of tabs, indentation size)."
},
"omnisharp.showReferencesCodeLens": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "csharp.showReferencesCodeLens". The "omnisharp.*" prefixed settings are intended to be for OmniSharp itself (though we diverged in one or two cases).

"type": "boolean",
"default": true,
"description": "Specifies whether Omnisharp should show the references CodeLens"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about: "Specifies whether the references CodeLens should be shown".

Remember that the extension isn't "OmniSharp".

}
}
},
Expand Down
8 changes: 8 additions & 0 deletions src/features/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -43,6 +44,13 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
};

provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
const options = Options.Read();
if (!options.showReferencesCodeLens)
{
let arr: vscode.CodeLens[] = [];
return arr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use just return [] here? Or, does TypeScript complain.

}

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));
Expand Down
16 changes: 14 additions & 2 deletions src/omnisharp/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +52,17 @@ export class Options {

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

return new Options(path, useMono, waitForDebugger, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings, useFormatting);
const showReferencesCodeLens = omnisharpConfig.get<boolean>('showReferencesCodeLens', true);

return new Options(path,
useMono,
waitForDebugger,
loggingLevel,
autoStart,
projectLoadTimeout,
maxProjectResults,
useEditorFormattingSettings,
useFormatting,
showReferencesCodeLens);
}
}