PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to exclude folders from processing

silverqx opened this issue · comments

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Is there any vscode setting how I can tell the PowerShell extension to exclude some folders?

Eg. look at this, it's from my dotfiles, the problem is that my dotfiles also contain the vscode profile in the git repo:

references_1

There are 5 references in total, 2 in the pms.ps1 script and 3 in the pmu.ps1, but the PowerShell extension of course counts references from all the .ps1 files in the current project (what is the correct behavior). What can I do about this?

I tried to add the path to the files.exclude and it isn't accepted, I don't even know if the files.exclude would be a good solution for this.

I am lacking some vscode setting that allows excluding for this extension, eg. powershell.exclude.

PowerShell Version

λ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

λ code --version
1.83.1
f1b07bd25dfad64b0167beb15359ae573aecd2cc
x64

Extension Version

λ code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2023.8.0

Steps to Reproduce

none

Visuals

No response

Logs

No response

    "search.exclude": {
        "vscodeglobpatternhere": true,
    },
    // or
    "powershell.analyzeOpenDocumentsOnly": true,

Thanks @silverqx this should be the setting

Essentially the extension respects the built-in search.exclude setting:

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

https://code.visualstudio.com/docs/getstarted/settings

The search.exclude doesn't work for me, it doesn't affect these References.

Also, I discovered that I already had these folders in the search.exclude and also in files.exclude but References are still counted from these folders.

I have something like this in my settings (I have replaced my personal paths with this <secret> strings, they are real paths in my settings):

{
    "files.exclude": {
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/globalStorage/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/History/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/sync/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/workspaceStorage/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Notepad++/backup/": true
    },
    "search.exclude": {
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/globalStorage/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/History/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/sync/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Code/User/workspaceStorage/": true,
        "dotfiles/<host-secret>/C/Users/<username-secret>/AppData/Roaming/Notepad++/backup/": true
    }
}

This issue has been marked as resolved and has not had any activity for 1 day. It has been closed for housekeeping purposes.