PowerShell / PowerShell/PSScriptAnalyzer

Indentation breaks using anything other than pipelineIndentationStyle: None using a second pipe within parenthesis

Abierto
#1,976 6 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Area - Formatter Issue-Bug Up-for-Grabs
Lenguaje dominante
C#
Estrellas
2.2k
Forks
414
Merge medio
13 h 1 min
PR fusionados (30 d)
2

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

The formatting of code breaks, not closing the indentation where it is logical. The conditions are highlighted in the Steps to reproduce section but it seems to be related to using both the pipe | and parenthesis () in multiple lines.

PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
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.86.2
x64
Extension Version
ms-vscode.powershell@2024.3.0
Steps to Reproduce
  1. Open a new file and paste this code:
1 | Select-Object (
    $_ |
        Write-Host
    )
Write-Host 'Indentation is broken'
  1. Format the document
  2. Write-Host is now indented at the same level as the closed parenthesis:
1 | Select-Object (
   $_ |
       Write-Host
   )
   Write-Host 'Indentation is broken'
Visuals

No response

Logs

No response

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el comportamiento de formateo en el PowerShell formatter con la canalización multilínea y la expresión entre paréntesis del issue. Rastrea cómo el formateo gestiona la segunda pipe y el paréntesis de cierre; estará terminado cuando el siguiente Write-Host permanezca en la indentación correcta del nivel superior después del formateo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
powershell, vscode
Área
tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.