PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.7k stars 490 forks source link

Syntax-based code folding unavailable in virtual workspaces #4051

Closed ctholloway closed 1 year ago

ctholloway commented 2 years ago

Prerequisites

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.0

Visual Studio Code Version

1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

Extension Version

ms-vscode.powershell@2022.6.1

Steps 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

RestrictedRepo TrustedRepo

Logs

Logs sent privately per troubleshooting article.

SydneyhSmith commented 2 years ago

Thanks, does this also reproduce for you without the Azure Repos extension?

ctholloway commented 2 years ago

Hi Sydney,

I am not having this issue outside of the Azure Repos, such as when I’m using local files. This is why I initially reported the bug to the Azure Repo Extension team but they punted it since they cannot reproduce with the PowerShell Extension disabled and neither can I. Unfortunately, as a team of PowerShell developers utilizing Azure Devops CICD, both of these extensions working in tandem are pretty crucial to our workflow. This issue started happening for us last week sometime.

Thanks,

Chris

From: Sydney Smith @.> Sent: Tuesday, June 28, 2022 11:40 AM To: PowerShell/vscode-powershell @.> Cc: Holloway, Chris @.>; Author @.> Subject: [EXTERNAL] Re: [PowerShell/vscode-powershell] Cannot Collapse Powershell code after trusting Azure Repo with Powershell Extension Enabled (Issue #4051)

WARNING This is an external email sent from: @.**@.>.

DO NOT CLICK links or attachments unless you recognize the sender.

ghost commented 2 years ago

This issue was closed automatically as repro info was indicated as needed, but there has been no activity in over a week. Please feel free to reopen with any available information!

ctholloway commented 2 years ago

My Repro Info is in Steps to Reproduce. Is anything further needed?

ctholloway commented 2 years ago

Collapse

andyleejordan commented 2 years ago

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 commented 2 years ago

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?

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.

andyleejordan commented 2 years ago

Well, so it makes me wonder what on earth their extension is doing to the folding. Since they're PowerShell scripts, I would think only the PowerShell extension (ours) would handle folding. But I'll see if I can repro this and find where the heck this bug is.

andyleejordan commented 2 years ago

Hey, can you tell me more clearly what you mean by "Install Azure Repos Extension"? When I found the "Azure Repos Extension" on GitHub it turns out that it's archived and deprecated. Moreover, because of that, I can't install the extension to test.

ctholloway commented 2 years ago

Hey, can you tell me more clearly what you mean by "Install Azure Repos Extension"? When I found the "Azure Repos Extension" on GitHub it turns out that it's archived and deprecated. Moreover, because of that, I can't install the extension to test.

Thank you much for taking a look, my teams' scrollwheels are taking a beating. We are using extension ID: ms-vscode.azure-repos

https://github.com/microsoft/vscode-remote-repositories-github https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-repos

andyleejordan commented 2 years ago

Ah, that's helpful thank you. I see on their readme:

There are certain limitations while working with virtual workspaces:

Debugging, terminals, and tasks are not currently supported. Terminals open on your local file system and don’t have access to the virtual file system of the remote repository. Limited language intelligence - Features like IntelliSense and go-to-definition may be impacted as many languages don't yet understand the virtualized environment of Azure Repos. Extensions - Not all extensions can support running in a virtual workspace, but over time more extensions will support it. For example, extensions that depend on direct access to local files won't be able to support this.

It sounds like it'll be a bit of work to investigate. The extension is certainly not setup as-is to understand this special "virtual workspace" they've created, but we can put it on our list to look at more closely.

andyleejordan commented 2 years ago

I'm linking for my future reference the VS Code information on how to support their Virtual Workspaces: https://github.com/microsoft/vscode/wiki/Virtual-Workspaces

The good news is that I recently migrated nearly all of the client's FS usage to the vscode.workspace.fs API, so a lot of that work is done already.

andyleejordan commented 2 years ago

@ctholloway as a temporary workaround, can you try setting powershell.codeFolding.enable to false? I know that sounds weird, but what it should do is disable the syntax-based folding in the extension (which is powered by LSP, and so not going to work in a virtual workspace) and instead fallback on the default indentation-based folding, which it sounds like is already working for you (as I think it's what's made available when you have the workspace set as untrusted).

ctholloway commented 2 years ago

Thanks for the info and for looking into this! If the day comes, we'll be happy to test a preview build of the powershell extension that enables virtual workspace support.

ghost commented 1 year ago

This issue has been marked as answered and has not had any activity in a day. It has been automatically closed for housekeeping purposes.