PowerShell / PowerShell/vscode-powershell

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

Offen
#4,745 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-Folding Issue-Enhancement
Vorherrschende Sprache
TypeScript
Sterne
1.9k
Forks
548
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Faltverhalten in VS Code mit dem bereitgestellten PowerShell-Beispiel, zunächst mit aktivierter und anschließend mit deaktivierter Erweiterung. Verfolge das Verhalten der Erweiterung, das sich auf das durch Kommentare eingeleitete Falten auswirkt; fertig ist es, wenn die Funktionen in .ps1- und .psm1-Dateien unter ihren kommentierten Zeilen gefaltet werden können, ohne die Erweiterung zu deaktivieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, typescript, vscode
Bereich
devtools, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.