vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Codelens shows references to files/folders excluded using "files.exclude" setting

Open oldlost opened this issue 9 years ago • 17 comments

System Details

  • Operating system name and version: Windows Server 2012 R2
  • VS Code version: 1.16.1
  • PowerShell extension version: 1.4.3
  • Output from $PSVersionTable:

Name Value


PSRemotingProtocolVersion 2.3
BuildVersion 10.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSVersion 5.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
SerializationVersion 1.1.0.1

Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

code -v
code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ code -v
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (code:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      4      1      0


PS> code --list-extensions --show-versions
code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ code --list-extensions --show-versions
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (code:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with codelens, in that the references it shows includes files and folders that are excluded using "files.exclude" in the settings file. Is this by design? Is there any way to exclude files and folders from the codelens references?

Attached Logs

I will be glad to attach logs if you think it will help, but I doubt logs will help with this issue.

oldlost avatar Sep 29 '17 19:09 oldlost

I'd love this too. As we've been moving to a function-per-file source "built" into single-file PSM1 modules, those psm1 files sometimes end up within the folder that I've selected as the root of a project -- this means they show up in go to definition and interfere with finding the file I needed to edit...

Jaykul avatar Oct 06 '17 19:10 Jaykul

Agree, great suggestion. I also use a build directory in the project root, code in src keeps being associated with references to code in build. It definitely slows down my workflow, checking if the reference is actually to the correct files.

For me personally, exclusion though "search.exclude" which implicitly includes "files.exclude" in the filter would be preferred. I often refer back to the build folder within VSCode, so hiding it within the explorer by using "files.exclude" would be less optimal.

ElinoraWhite avatar Oct 10 '17 08:10 ElinoraWhite

If you use a local history extension, you will end up to 10.000+ found references very quickly. Codelens and even IntelliSense will just stop working then. My first workaround was deactivating codelens. Now I just moved the local history folder outside the workspace folder.

It would be sufficient, if VSCode ignores ALL hidden files and folders by default (or by settings), instead of using ignore lists, since most folders you wish to ignore (like .history .vs .vscore .git .svn...) are hidden by default.

ghost avatar May 20 '18 10:05 ghost

This is a reasonable request. However, I think rather than using files.exclude we should have our own setting for codelens - maybe something like:

powershell.codelens.exclude

Ideally vscode could have a codelens.exclude. This would be useful for other dynamic languages as well.

files.exclude has more to do with what shows up in the workspace (like .git) and users might want to see published output in their workspace.

TylerLeonhardt avatar May 22 '18 21:05 TylerLeonhardt

And we'll make sure to talk to someone on the VS Code team before we walk down an implementation path.

But in either case, this would roughly halve the number of files we're analyzing for modules who use a build/publish folder structure, so I think it's important to the perf/stability work as well.

joeyaiello avatar May 22 '18 21:05 joeyaiello

And maybe we do what this setting does:

  // Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the files.exclude setting.
  "search.exclude": {
    "**/node_modules": true,
    "**/bower_components": true
  },

inherits its default value from file.exclude as a starting point. Or maybe we inherit from search.exclude as has been suggested earlier in this thread?

rkeithhill avatar May 22 '18 21:05 rkeithhill

Hello, Are there any developments on this? Any time / release plan? Any help needed? I'm looking for this as well, and would love to contribute to solution if required & possible. Kind Regards,

caparkaya avatar Jul 29 '18 19:07 caparkaya

Hi @caparkaya, sorry we've been a bit busy lately. It looks like there is a desire for this, but it's currently not being worked on. There might still be the odd thing to discuss, like:

  • What should the option be called?
  • Should CodeLens and debug optout be given the same option?
  • Does it make sense to not use VSCode's files.exclude? (I think we've already agreed that we shouldn't use it, but just enumerating considerations)
  • What should a default be?

The other thing that still needs to happen is @joeyaiello's requirement:

And we'll make sure to talk to someone on the VS Code team before we walk down an implementation path.

@tylerl0706 @rkeithhill @SeeminglyScience any thoughts here?

rjmholt avatar Aug 01 '18 19:08 rjmholt

Oh, meant to add... @caparkaya we are always over the moon to accept contributions -- feel free to open a PR anytime! Contributions also get mentioned in the CHANGELOG.

rjmholt avatar Aug 01 '18 19:08 rjmholt

This is much needed. Indexing the .history folder is awful. I always end up with references to some history version of a file. Total nightmare.

lllopo avatar Feb 07 '19 12:02 lllopo

There should be a custom setting (or a codelens.exclude) so the extension can exclude things from parsing that we still want to have show up in the sidebar file list.

However, like search.exclude that new setting must inherit files.exclude regardless. It should probably inherit search.exclude -- but I'm not totally set on that.

The point is that you shouldn't spend time parsing files that aren't even visible to the user -- and the user shouldn't have to add additional exclusions if they've already hidden the files.

Jaykul avatar Mar 01 '19 19:03 Jaykul

@Jaykul Just to confirm, you're talking about ignoring files for the;

(The reason I ask is the term CodeLens has a very specific meaning in the Language Server Protocol)

  • The references intellisense item image

  • The Goto Definition and Peek Definition intellisense items

glennsarti avatar Mar 04 '19 12:03 glennsarti

For reference: I'll probably need to import https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing into PSES to help with the globs that come from files.exclude

glennsarti avatar Mar 04 '19 12:03 glennsarti

@glennsarti the package you referenced I did evaluate. I tried using it for the RecursivelyEnumerateFiles function in PSES and there was no way to handle any file access exceptions... It would just stop the whole glob operation.

This was the really good one I found: https://github.com/mganss/Glob.cs

TylerLeonhardt avatar Mar 04 '19 22:03 TylerLeonhardt

Cross reference https://github.com/PowerShell/PowerShellEditorServices/pull/877

glennsarti avatar Mar 16 '19 13:03 glennsarti

My PSES PR is making great headway into this. Won't be too long now.

glennsarti avatar Mar 16 '19 14:03 glennsarti

Closing as the fix has been merged and will be available in the next preview release

SydneyhSmith avatar May 24 '19 18:05 SydneyhSmith