`Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text

オープン
#2,211 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
powershell
領域
tooling

調査の方向性

Invoke-Formatter -Range エントリポイントから始め、指定された PSScriptAnalyzer のバージョンで提示されたコマンドを再現します。選択した範囲に対して反復的なフォーマット修正がどのようにフィルタリングされるかを追跡し、その後、完全なステートメント内のすべての修正が適用されることを、} の前の最後のスペースも含めて確認します。

索引モデルが issue の本文から書いたものです。

説明

Steps to reproduce

Format only the second line, with the range covering the complete statement:

Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12)

Expected behavior

Every formatting correction within the selected statement should be applied:

if($a){'x'}
if ($b) { 'y' }

Actual behavior

The space before the final } is missing:

if($a){'x'}
if ($b) { 'y'}

The formatter applies fixes iteratively. Earlier corrections make the selected line longer, but later violations are still filtered against the original fixed range coordinates. Once a correction shifts beyond the original range end, it is silently dropped even though it belongs to the statement selected by the caller.

Expected resolution

Track the range through applied edits, or filter corrections once against their original extents, so that a range covering a complete statement formats that statement completely.

Environment data

Reproduced with:

  • PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2
  • PSScriptAnalyzer built from main at PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4
主要言語
C#
スター
2.2k
フォーク
415
平均マージ
13時間 1分
マージ済み PR(30日)
2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PowerShell/PSScriptAnalyzer のほかの issue

PowerShell/PSScriptAnalyzer の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。