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

Syntax-based code folding unavailable in virtual workspaces

Open ctholloway opened this issue 2 years ago • 14 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.
  • [X] I have read the troubleshooting guide.
  • [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • [X] 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.0

Visual Studio Code Version

1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

Extension Version

[email protected]

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.

ctholloway avatar Jun 27 '22 21:06 ctholloway

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

SydneyhSmith avatar Jun 28 '22 18:06 SydneyhSmith

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.

ctholloway avatar Jun 28 '22 18:06 ctholloway

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!

ghost avatar Jul 06 '22 19:07 ghost

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

ctholloway avatar Jul 07 '22 17:07 ctholloway

Collapse

ctholloway avatar Sep 09 '22 22:09 ctholloway

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?

andyleejordan avatar Sep 12 '22 16:09 andyleejordan

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.

ctholloway avatar Sep 12 '22 17:09 ctholloway

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 avatar Sep 12 '22 20:09 andyleejordan

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.

andyleejordan avatar Sep 12 '22 20:09 andyleejordan

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

ctholloway avatar Sep 12 '22 21:09 ctholloway

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 avatar Sep 13 '22 00:09 andyleejordan

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 avatar Sep 13 '22 00:09 andyleejordan

@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).

andyleejordan avatar Sep 13 '22 00:09 andyleejordan

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.

ctholloway avatar Sep 13 '22 00:09 ctholloway

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

ghost avatar Feb 10 '23 21:02 ghost