Repository navigation
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all 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
I originally opened this bug with the Azure Repo extension team but subsequent troubleshooting shows this issue only occurs when the PowerShell Extension is enabled. I have tried rolling back the PowerShell extension from v2022.6.1 to 2022.5.1 and the issue still occurs. After disabling the PowerShell Extension I can no longer reproduce the error described below.
After connecting to an Azure Repo and trusting the repo in Manage Workspace trust, the code collapse arrows disappear and we cannot collapse various codeblocks. Previously collapsed code expands. Putting the repo back in Restricted mode resolves the issue immediately. We are not having any issues with local files or any files not contained in our Azure Repo. This issue appeared recently and occurs for multiple users on my team and on multiple computers. We have PowerShell scripts in our repo. This issue occurs for us on both the stable and prerelease version of Azure Repo.
Azure Repo Version:
v0.12.0
PowerShell Version
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visual Studio Code Version
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64Extension Version
ms-vscode.powershell@2022.6.1Steps to Reproduce
Install Azure Repos Extension
Install PowerShell Extension
Connect to script hosted in Azure Remote Repo
Collapsing Codeblock works.
Trust Repo in Manage Workspace Trust
Collapsed codeblocks expand, can no longer click collapse.
Set Repo to restricted in Manage Workspace Trust, issue immediately resolves
Disable PowerShell Extension
Reload VSCode
Blocks now collapse as expected in Both Restricted and Trusted Mode
Visuals
Logs
Logs sent privately per troubleshooting article.
Activity
SydneyhSmith commentedon Jun 28, 2022
Thanks, does this also reproduce for you without the Azure Repos extension?
ctholloway commentedon Jun 28, 2022
ctholloway commentedon Jul 7, 2022
My Repro Info is in Steps to Reproduce. Is anything further needed?
ctholloway commentedon Sep 9, 2022
andyleejordan commentedon Sep 12, 2022
If you have only the PowerShell extension installed, and not the Azure Repos extension, can you collapse the blocks are you're expecting to be able to?
ctholloway commentedon Sep 12, 2022
Correct. This only happens in Azure Repos once the repo has been trusted. It also only happens in Azure Repos with the powershell extension installed (as of sometime in May). Everything was groovy before that. Per my initial comment, I did report this to the Azure Repos Team and they said that because it only happens with the powershell extension installed it's not their problem. Of course, the inverse can be said as well. My issue lives in the spot of the vin diagram where it's in nobody's scope of support.
18 remaining items
github-actions commentedon Apr 2, 2026
🎯 Agentic Issue Triage
Summary: When PowerShell files are opened inside a virtual workspace (e.g. Azure DevOps Repos via the Remote Repositories extension), the PowerShell extension's syntax-based code folding stops working once the workspace is trusted. The LSP-powered folding provider registers itself but the language server cannot run in a virtual workspace, leaving users with no folding at all.
The issue has been present since at least 2022 and a recent comment (2026) confirms the previously suggested workaround (
powershell.codeFolding.enable: false) no longer resolves it.🔍 Root Cause Analysis
The PowerShell extension provides syntax-based folding via the Language Server (LSP
textDocument/foldingRange). In a virtual workspace, VS Code restrictions prevent spawning local processes, so the language server never starts. However, the extension still registers itself as the folding provider for.ps1/.psm1files (vialanguages.registerFoldingRangeProvider), overriding VS Code's built-in indentation-based fallback — leaving the user with zero folding.Key facts:
powershell.codeFolding.enablewas supposed to deregister the provider, but users now report this no longer helps.The VS Code Virtual Workspaces guide notes that extensions should declare their virtual workspace capabilities in
package.jsonand avoid registering providers that require local processes.🛠 Suggested Fix Approaches
Declare virtual workspace support level in
package.jsonAdd a
capabilities.virtualWorkspacesentry topackage.jsonto signal limited support. This can prevent the folding provider from being registered when no language server is available:Guard folding provider registration on workspace type
Before registering the
FoldingRangeProvider, check whether the workspace is virtual (i.e., the URI scheme is notfile:). If virtual, skip registration to allow VS Code's built-in folding to take over:Implement a lightweight regex-based folding provider (longer term)
Implement a pure-syntax folding provider (without LSP) using regex to detect
{/},begin/end,#region/#endregion, etc. This would work even without the language server and enable proper folding in virtual workspaces.🔄 Reproduction Steps
.ps1files.@JustinGrote: Does this also reproduce with a plain GitHub repo via "Open Remote Repository"? This would confirm whether the issue is Azure DevOps-specific or a general virtual workspace problem.📂 Relevant Code Areas
Look for folding provider registration in the extension source, likely in:
src/features/folding.ts(or similar) — wherevscode.languages.registerFoldingRangeProvideris calledpackage.json—capabilitiessection for virtual workspace declarationsReference: VS Code Virtual Workspaces wiki
✅ Sub-tasks / Checklist
capabilities.virtualWorkspacesinpackage.jsonpowershell.codeFolding.enable: falseno longer falls back to built-in foldingDanGilbertTX commentedon Apr 2, 2026
I will test that in the morning and report back. I can take a video if that would help.
andyleejordan commentedon Apr 2, 2026
I need to actually configure this, because this was useless, but I want to set it up to auto close obvious spam issues, of which we have a lot.
DanGilbertTX commentedon Apr 3, 2026
Yes. It actually installs the 3 Remote extensions when you click on it. I started with a new install of VSCode in a VM to test this just to make sure I wasn't bringing crap over. I installed PowerShell extension and nothing else. Then clicked Remote Repository like you asked. Of note, when I start VSCode and/or first connect, it does show the folding carats. Those go away after a few seconds. My guess is that it is the virtual workspace issue.
Here are screenshots of connecting, what it looks like untrusted, and what it looks like trusted:
DanGilbertTX commentedon Apr 3, 2026
Also, putting the workspace back to restricted mode is not giving me the option to fold. It disables the PowerShell extension.
ctholloway commentedon Jun 8, 2026
Just an update since this was reopened, code folding still does not work for me. I'm even on a new image from when I originally opened the issue. It used to work, it broke several years ago and has remained broken ever since in the remote repos. My experience is identical to Dan's.
JustinGrote commentedon Jun 9, 2026
Thanks for the update! We do know that the semantic highlighting has some issues after a regression we are planning to fix, can you try disabling semantic highlighting and see if it persists?
DanGilbertTX commentedon Jun 9, 2026
I assume you mean the
editor.semanticHighlightingsetting in VSCode. I checked mine and it was set for both User/Workspace asConfiguredByTheme. I changed it tofalseand folding is still broken.Of note, when I changed it and went back, semantic highlighting is still
Enabled. It also says it is modified elsewhere (see screenshot). I have clicked those and set it tofalsein all those places and semantic highlighting still seems to be Enabled. I made sure it was false in all places I could search forsemantic. I rebooted the computer as well; just to make sure that wasn't something that was needed.This is a Win11 test VM with nothing but VSCode on it, the Remote Repositories extension and the PowerShell extension. This is my userspace settings.json. The workspace settings.json has the same except no
workbench.colorThemeline.Is there some other way/place I am supposed to disable it?
JustinGrote commentedon Jun 9, 2026
Nope that should do it. Thanks!
Since virtual workspaces is a relatively new (Sept 2025) feature I'm sure there's some stuff we need to fix to update for it. It would definitely be partial support as parts of the extension cannot work today with virtual file paths, they must be absolute local file paths on the file system due to how PowerShell works.
https://github.com/microsoft/vscode/wiki/Virtual-Workspaces#what-are-the-expectations-for-language-support-with-virtual-workspaces
Things like code folding should be doable within a single file however.