PowerShell / PowerShell/PSScriptAnalyzer
`Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 414
- Merge trung bình
- 13 giờ 1 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
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
mainat PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với điểm vào Invoke-Formatter -Range và tái hiện lệnh được cung cấp trên các phiên bản PSScriptAnalyzer đã nêu. Theo dõi cách các hiệu chỉnh định dạng lặp lại được lọc theo phạm vi đã chọn, sau đó xác minh rằng mọi hiệu chỉnh trong toàn bộ câu lệnh đều được áp dụng, bao gồm cả khoảng trắng cuối cùng trước }.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- powershell
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100