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
- 派生
- 414
- 平均合并
- 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