You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable "n reference(s)" display for functions #924
Bill Stewart (@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.:
Thanks Keith Hill (@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).
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.
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.
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.
Reacted by TylerLeonhardt, Rob Holt and Andy Jordan
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:
There is a (relatively) recent issue posted in the VSCode repo: microsoft/vscode#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: microsoft/vscode#23652 (comment) , 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: microsoft/vscode#90235 , and in particular I wanted to draw attention to baybal's intriguing suggestion here: microsoft/vscode#73413 (comment)
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: microsoft/vscode#90235 (comment) , 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.
Use the setting powershell.enableReferencesCodeLens to disable code lenses for just the PowerShell extension (but also, try them out again, they're much faster now!)
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.
Keith I just want you to know you're right, that would have been a much better name and I wish I'd seen this.
Activity
daviwil commentedon Jun 26, 2017
Not currently, but I'll add a setting for it.
rkeithhill commentedon Jun 26, 2017
Bill Stewart (@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.:
daviwil commentedon Jun 26, 2017
Thanks Keith! Didn't know there was a switch at the editor level :)
Bill-Stewart commentedon Jun 26, 2017
Thanks Keith Hill (@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).
Bill-Stewart commentedon Jun 26, 2017
Thanks David Wilson (@daviwil) - If we can turn off that display, that would be great!
rkeithhill commentedon Jun 26, 2017
So does that mean you want the
Run Tests | Debug Testscode 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).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.
Bill-Stewart commentedon Jun 27, 2017
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).
daviwil commentedon Jun 27, 2017
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.
Bill-Stewart commentedon Jun 27, 2017
Sure, that workaround is fine for now. Thanks!
mattmcnabb commentedon Jun 27, 2017
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.
6 remaining items
TylerLeonhardt commentedon Apr 26, 2019
It should be. If you're experiencing trouble, please let us know.
musm commentedon Apr 26, 2019
Can you add the option
"powershell.referencesCodeLens.enabled": true
so only references are disabled?
TylerLeonhardt commentedon Apr 26, 2019
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.
rkeithhill commentedon Apr 27, 2019
Sounds reasonable to me but I'd prefer a setting name like
powershell.codeLens.ReferenceProvider.enabledor something like that. That way, if we were to add more code lens settings, they'd sort together.AltitudeApps commentedon Aug 30, 2020
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:
There is a (relatively) recent issue posted in the VSCode repo: microsoft/vscode#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: microsoft/vscode#23652 (comment) , 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: microsoft/vscode#90235 , and in particular I wanted to draw attention to baybal's intriguing suggestion here: microsoft/vscode#73413 (comment)
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: microsoft/vscode#90235 (comment) , 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.
fflaten commentedon Feb 12, 2023
This should now be fixed by #4139
andyleejordan commentedon Feb 13, 2023
Use the setting
powershell.enableReferencesCodeLensto disable code lenses for just the PowerShell extension (but also, try them out again, they're much faster now!)andyleejordan commentedon Feb 13, 2023
Keith I just want you to know you're right, that would have been a much better name and I wish I'd seen this.