Before submitting a bug report:
Note: this has nothing to do with VSCode, only the Invoke-Formatter cmdlet.
Steps to reproduce
Save the following file as test.ps1:
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
$knownProperties = @()
Get-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {
[xml]$pom = Get-Content $_
$knownProperties += $pom.project.properties.getEnumerator() |
Where-Object name -NE '#comment' |
ForEach-Object name
}
Get-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {
[xml]$report = Get-Content $_
$report.PropertyUpdatesReport.properties.property |
Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }
} | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique
Then, run the formatter:
Invoke-Formatter -ScriptDefinition (Get-Content -Raw -Path ./test.ps1)
Expected behavior
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
$knownProperties = @()
Get-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {
[xml]$pom = Get-Content $_
$knownProperties += $pom.project.properties.getEnumerator() |
Where-Object name -NE '#comment' |
ForEach-Object name
}
Get-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {
[xml]$report = Get-Content $_
$report.PropertyUpdatesReport.properties.property |
Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }
} | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique
Actual behavior
The second line starting with Get-ChildItem gets indented and all its pipeline, for no apparent reason:
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
$knownProperties = @()
Get-ChildItem -Path . -Recurse -Filter pom.xml | ForEach-Object {
[xml]$pom = Get-Content $_
$knownProperties += $pom.project.properties.getEnumerator() |
Where-Object name -NE '#comment' |
ForEach-Object name
}
Get-ChildItem -Path . -Recurse -Filter property-*-report.xml | ForEach-Object {
[xml]$report = Get-Content $_
$report.PropertyUpdatesReport.properties.property |
Where-Object { $_.lastVersion -NE $null -and $_.propertyName -in $knownProperties }
} | Select-Object propertyName, lastVersion | Sort-Object propertyName -Unique
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Darwin 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
Before submitting a bug report:
Note: this has nothing to do with VSCode, only the
Invoke-Formattercmdlet.Steps to reproduce
Save the following file as
test.ps1:Then, run the formatter:
Expected behavior
Actual behavior
The second line starting with
Get-ChildItemgets indented and all its pipeline, for no apparent reason:Environment data