PowerShell / PowerShell/vscode-powershell

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

Aperta
#4,745 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Folding Issue-Enhancement
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il comportamento di folding in VS Code con l’esempio PowerShell fornito, prima con l’estensione abilitata e poi disabilitata. Traccia il comportamento dell’estensione che influisce sul folding guidato dai commenti; il lavoro è completato quando le funzioni possono essere sottoposte a folding sotto le rispettive righe commentate nei file .ps1 e .psm1 senza disabilitare l’estensione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, typescript, vscode
Ambito
devtools, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.