Enabling `powershell.codeFormatting.whitespaceBetweenParameters` and `powershell.codeFormatting.alignPropertyValuePairs` makes one of them always show a warning for Hashtable assignments
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- powershell, typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Tái hiện cảnh báo với powershell.codeFormatting.whitespaceBetweenParameters và powershell.codeFormatting.alignPropertyValuePairs được bật, sử dụng các ví dụ hashtable nhiều dòng trong issue. Bắt đầu bằng cách theo dõi cách extension xử lý các tùy chọn PSScriptAnalyzer PSAlightAssignmentStatement CheckHashtable và PSUseConsistentWhitespace IgnoreAssignmentOperatorInsideHashTable. Hoàn tất khi các phép gán hashtable được căn chỉnh với một dấu cách sau toán tử không tạo ra các cảnh báo xung đột khi cả hai thiết lập đều được bật.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
When having both powershell.codeFormatting.whitespaceBetweenParameters and powershell.codeFormatting.alignPropertyValuePairs enabled in the extension settings, the editor UI will always show the warning for one or the other. So multi-line hashtable assignments always have a yellow warning line under all of the key-value pairs, except the one that has the longest key-string.
In PSScriptAnalyzer, there is an option in the arguments for each of the two rules:
for PSAlightAssignmentStatement, there's CheckHashtable
for PSUseConsistentWhitespace there's IgnoreAssignmentOperatorInsideHashTable
If both of these respective options are enabled, the hashtable assignments receive no warnings when the = operators are aligned and there's only 1 space after.
The PowerShell VSCode extension should either detect when the two settings are enabled and enable the respective arguments automatically or offer the option to enable or disable the respective arguments if the settings are enabled so that multi-line hashtable assignments don't always receive warnings.
PowerShell Version
Name Value
---- -----
PSVersion 7.6.6
PSEdition Core
GitCommitId 7.6.6
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : ConsoleHost
Version : 7.6.6
InstanceId : d8f39d3e-72c7-47bd-87fd-71c8a5f05138
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
1.137.0
645f29cc3176500b4b5762ba887cf2a7f0ffdf2c
x64
Extension Version
[email protected]
Steps to Reproduce
In VSCode Settings, enable both powershell.codeFormatting.whitespaceBetweenParameters and powershell.codeFormatting.alignPropertyValuePairs, then create a simple hashtable with multiple key-value pairs that have different legths of key-strings.
With Alignment:
$myHashtable = @{
KeyOne = 'item' # <- Warning: Use space before and after binary and assignment operators.
Key2 = $aVariable # <- Warning: Use space before and after binary and assignment operators.
KeyThree = 'ThirdValue' # <- No warning
KeyFour = $otherVariable # <- Warning: Use space before and after binary and assignment operators.
}
return @{
Item1 = $false # <- Warning: Use space before and after binary and assignment operators.
ItemTwo = 2 # <- Warning: Use space before and after binary and assignment operators.
ItemThree = $true # <- No warning
}
Without Alignment:
$myHashtable = @{
KeyOne = 'item' # <- Warning: Assignment statements are not aligned.
Key2 = $aVariable # <- Warning: Assignment statements are not aligned.
KeyThree = 'ThirdValue' # <- No warning
KeyFour = $otherVariable # <- Warning: Assignment statements are not aligned.
}
$myHashtable
return @{
Item1 = $false # <- Warning: Assignment statements are not aligned.
ItemTwo = 2 # <- Warning: Assignment statements are not aligned.
ItemThree = $true # <- No warning
}
Visuals
Logs
No response
- Ngôn ngữ chính
- TypeScript
- Star
- 1.9k
- Fork
- 549
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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.
Issue khác của PowerShell/vscode-powershell
-
[aw] Agentic Issue Triage failedĐang mởagentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PowerShell/vscode-powershell#5615 · 1 bình luận ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
PowerShell/vscode-powershell#5607 ·
-
[aw] Agentic Issue Triage failedĐang mởagentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
PowerShell/vscode-powershell#5599 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PowerShell/vscode-powershell#5592 · 2 bình luận · 1 reaction ·
-
[aw] Agentic Issue Triage failedĐang mởagentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
PowerShell/vscode-powershell#5583 · 1 bình luận ·
Tất cả issue của PowerShell/vscode-powershell
Issue tương tự
-
fix(data-lake): wizard source step still previews the local slug, not the server-disambiguated oneĐang mởdata-lake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue priority: low size: XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Empty label or headline exports the editor hint ("LABEL" / "Headline goes here") into the PNGĐang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Spray wall wizard: Done button on the hold review step sits under the navigation header (iOS)Đang mởbug ios mobile priority:P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
streamplace/streamplace#1351 ·
Maintainer thường phản hồi trong vòng 2 ngày