PowerShell / PowerShell/PSScriptAnalyzer
Indentation breaks using anything other than pipelineIndentationStyle: None using a second pipe within parenthesis
未關閉
還沒有人認領這個 Issue。
Area - Formatter
Issue-Bug
Up-for-Grabs
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,使用 issue 中的多行管線和括號表達式,重現 PowerShell formatter 中的格式化行為。追蹤格式化如何處理第二個管線和右括號;完成的標準是,格式化後,後續的 Write-Host 仍保持在正確的頂層縮排位置。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell, vscode
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100