PowerShell / PowerShell/PSScriptAnalyzer
Whitespace removed when "Code Formatting: Whitespace Around Operator" Enabled
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Prerequisites
- I have written a descriptive issue title.
- I have searched all 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.
Summary
When enabling the "Whitespace Around Operator" formatting option, which description reads "Adds spaces before and after an operator...", the setting will also remove redundant whitespace around operators, despite the description not detailing that.
This means that if a user deliberately adds additional whitespace in order to line up declarations, that deliberate extra whitespace is removed and their declarations no longer cleanly line up.
From my perspective, the removal of the additional whitespace should be moved to it's own separate preference, which is how it already operates for "Add Whitespace Around Pipe" and "Trim Whitespace Around Pipe". For these settings related to pipes, the Add setting only adds, and the Trim setting only removes. Or at the very least, the dual nature of "Whitespace Around Operator" should be detailed in it's description.
While not directly related to the bug itself, I could also very easily see an argument being made to have an option similar to "Align Property Value Pairs" when multiple variable declarations are made on consecutive lines, like in the instance of my example below. At least for my personal preference a setting like that could also be an reasonable solution to this problem.
PowerShell Version
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19042
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.64.2
f80445acd5a3dadef24aa209168452a3d97cc326
x64
Extension Version
ms-vscode.powershell@2021.12.0
Steps to Reproduce
- Enable the "Code Formatting: Whitespace Around Operator" preference
- Write code with multiple spaces between variable name and operator
- Apply formatting
Visuals
Input
$foo = 'bar'
$testing = 'stuff'
$month='March'
Expected behavior (based on description text that only mentions adding whitespace)
$foo = 'bar'
$testing = 'stuff'
$month = 'March'
Actual behavior
$foo = 'bar'
$testing = 'stuff'
$month = 'March'
Logs
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、"Whitespace Around Operator" 設定と issue に示されている変数宣言を使って、フォーマット動作を再現します。formatter の実装と関連するテストを調査してください。report にはファイルパスやテストパスが記載されていません。既存の余分な空白の処理と、文書化された add-whitespace の動作に一貫性があり、報告された入力に対するカバレッジがあれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100