Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell Extension breaks Standard VSCode comment line code folding for .ps1 and .psm1 files #4745

Open
5 of 6 tasks
RalfReddings opened this issue Sep 20, 2023 · 0 comments
Labels
Area-Folding Issue-Enhancement A feature request (enhancement).

Comments

@RalfReddings
Copy link

RalfReddings commented Sep 20, 2023

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

In VSCode you can fold entire blocks of code that are indented under a commented out line. I use this everywhere in other languages to organise my code, in PowerShell this simply does not work.

Today, I set out to find out why. Turns out the PowerShell extension is interfering, In the following example, only the PowerShell extension is enabled (you can see on the right, all other extensions are greyed out, I made sure to reload after).

At the start, I cannot fold any of the functions under their respective commented out lines, the code folding arrow for the commented out lines will not even show in the gutter.

When I disable the PowerShell extension and reload the window, I can fold both functions under their respective commented out lines.

Trying various configurations of "powershell.codeFolding.enable": false and "powershell.codeFolding.showLastLine": false, did not solve the issue. I am not sure what these lines are for but I did try various true/false settings, did not work.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.22621
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

Version:          Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z)
OS Version:       Windows_NT x64 10.0.22621
CPUs:             AMD Ryzen 9 5950X 16-Core Processor             (32 x 3400)
Memory (System):  127.93GB (99.32GB free)
VM:               0%
Screen Reader:    no

Extension Version

v2023.6.0

Steps to Reproduce

With the Powershell extension enabled try to fold the function under their respective commented out lines:


#------- Function 1 ------
	function Foo {
		param (
			$Foo
		)
		begin{}
		process{}
		end{}
	}
#------- Function 2 ------
	function Foo {
		param (
			$Foo
		)
		begin{}
		process{}
		end{}
	}

Then disable the extension, reload the window and try the same thing again with the above code, it should work this time around.

Visuals

No response

Logs

No response

@RalfReddings RalfReddings added the Issue-Bug A bug to squash. label Sep 20, 2023
@RalfReddings RalfReddings changed the title PowerShell Extension breaks Standard VSCode comment line code folding for .ps1 and .psm1 files PowerShell Extension breaks Standard VSCode comment line code folding for .ps1 and .psm1 files Sep 20, 2023
@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). and removed Feature Request labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Folding Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

3 participants