PowerShell / PowerShell/PSScriptAnalyzer
Indentation breaks using anything other than pipelineIndentationStyle: None using a second pipe within parenthesis
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
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
- Open a new file and paste this code:
1 | Select-Object (
$_ |
Write-Host
)
Write-Host 'Indentation is broken'
- Format the document
Write-Hostis 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the formatting behavior in the PowerShell formatter with the multi-line pipeline and parenthesized expression from the issue. Trace how formatting handles the second pipe and closing parenthesis; done means the following Write-Host remains at the correct top-level indentation after formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100