PowerShell / PowerShell/vscode-powershell
PowerShell Extension breaks Standard VSCode comment line code folding for `.ps1` and `.psm1` files
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.9k
- Forks
- 548
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el comportamiento de plegado en VS Code con el ejemplo de PowerShell proporcionado, primero con la extensión habilitada y después deshabilitada. Rastrea el comportamiento de la extensión que afecta al plegado iniciado por comentarios; se considera terminado cuando las funciones se pueden plegar bajo sus líneas comentadas en archivos .ps1 y .psm1 sin deshabilitar la extensión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- powershell, typescript, vscode
- Área
- devtools, tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100