Vscode-powershell: Disable "n reference(s)" display for functions

Created on 26 Jun 2017  路  16Comments  路  Source: PowerShell/vscode-powershell

Is there a way to turn this off? Thanks!

Area-Configuration Issue-Enhancement

Most helpful comment

Not currently, but I'll add a setting for it.

All 16 comments

Not currently, but I'll add a setting for it.

@Bill-Stewart If you want to turn off all code lens support in PowerShell scripts, then you can do that now with your user settings. Press Ctrl+, and add this to the end e.g.:

"[powershell]": {
    "editor.codeLens": false
}

Thanks Keith! Didn't know there was a switch at the editor level :)

Thanks @rkeithhill - I don't want to disable all of code lens - just the references thing on functions that takes up vertical screen real-estate and creates a strange editing experience (weird line height on function lines).

Thanks @daviwil - If we can turn off that display, that would be great!

So does that mean you want the Run Tests | Debug Tests code lens disabled as well? These take up vertical screen real-estate. Just trying to understand the ask because the extension adds more than one type of code lens (function references and Pester test run/debug support).

I don't want to disable all of code lens

Do you mean for PowerShell or for all languages? If you meant "all languages" then the setting I showed above disables code lens just for PowerShell scripts. Then again, if you use say GitLens then you wouldn't get the Git commit info code lens. Of course, if you have any code lens enabled it will occupy the same amount of vertical space.

I meant just the part that says "n reference(s)" under the function name. It creates distracting screen jumping when cursoring past them up or down, particularly in RDP (and I use vscode in RDP quite a bit).

If you use the setting that Keith gave you, those things will disappear. Keith was referring to another set of those items that show up over Pester tests, but you probably wouldn't want to see those either since they would take up the same screen real estate. I'd say using Keith's setting would be the most expedient approach to disable them right now until we can add one to the extension.

Sure, that workaround is fine for now. Thanks!

See this feature request for VSCode

I love CodeLens, but I wish that it offered a different way to display the markers - it does feel a bit clumsy sometimes when these things interrupt your code's visual flow.

I was searching for this issue, since I too find them insanely distracting. So is the work around still

"[powershell]": {
    "editor.codeLens": false
}

It should be. If you're experiencing trouble, please let us know.

Can you add the option

"powershell.referencesCodeLens.enabled": true

so only references are disabled?

Yes, that is something that can be added - and based on the history that seems to be what this issue is tracking.

I can't say that it's the highest priority issue right now though but it's something we should add.

Sounds reasonable to me but I'd prefer a setting name like powershell.codeLens.ReferenceProvider.enabled or something like that. That way, if we were to add more code lens settings, they'd sort together.

This class of issues regarding how code lens tampers with the presentation and layout of the user's document has been going on for years, even preceding the existence of VSCode. For example:

|||
|-|-|
| developercommunity.visualstudio.com - Why can I not disable the Codelens show references | circa 2017 |
| StackExchange - How to turn off CodeLens-References - circa 2013 | circa 2013|

There is a (relatively) recent issue posted in the VSCode repo: https://github.com/microsoft/vscode/issues/90235 , which has links back to other tickets where this persistently recurring topic has been discussed, going as far back as 2017. _(If not earlier, but that is as far back as I've found so far.)_

I find this feature to be unbelievably irritating, in spite of its inherent usefulness. I have just "switched it off" completely for years. But I just recently started working on a box where I haven't worked before, and after I installed the C# extension, the "code-lens references" issue popped up again, and has been plaguing me for days. Now I'm seeing it in PowerShell. I must have disabled it completely years ago on my other setups, because I don't ever remember seeing code-lens happening in any of my PowerShell editing. (And I have a lot, going back years.)

I don't want to just turn the whole thing off, but that's what I've done just now. Because sanity.

In any case, the problem is harder than it looks, as discussed here: https://github.com/microsoft/vscode/issues/23652#issuecomment-304025993 , but I wanted to let this audience know that the larger discussion about how this problem might be tackled may be starting up again here: https://github.com/microsoft/vscode/issues/90235 , and in particular I wanted to draw attention to @baybal's intriguing suggestion here: https://github.com/microsoft/vscode/issues/73413#issuecomment-491590482

1

By the way, I found this thread via a search: https://www.google.com/search?q=%22powershell%22+turn+off+codelens , which I did in frustration after having been able to turn off the code-lens references in C# yesterday, but upon opening a .ps1 file today... Arrghh! There it is again !!

My rather involved thoughts on the topic can be found in this comment: https://github.com/microsoft/vscode/issues/90235#issuecomment-683347729 , where I basically applaud @baybal's mockups, but suggest that the gutter for code-lens should be on the right, with the other cues about information which is semantic in nature.

Was this page helpful?
0 / 5 - 0 ratings