You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting powershell.codeFormatting.pipelineIndentationStyle to "IncreaseIndentationForFirstPipeline" or "IncreaseIndentationAfterEveryPipeline" causes every line after a single-line pipeline to be un-indented by an extra level. Setting the value to the default "NoIndentation" value, pipelines are ignored and indentation behaviour returns to that which was provided in the previous release of vscode-PowerShell.
Use this code for example:
function Test-Function ($FullPath) {
if ($FullPath) {
# These lines have pipelines split over two lines. They indent as expected.
$Path = $FullPath |
Split-Path -Parent
$FileName = $FullPath |
Split-Path -Leaf
# These lines have full pipelines. Each removes an additional indentation.
$Path = $FullPath | Split-Path -Parent
$FileName = $FullPath | Split-Path -Leaf
$Path = $Path.Trim()
$FileName = $FileName.Trim()
return Join-Path $Path $FileName
}
}
Expected Behaviour
If a line contains a complete pipeline (i.e., one that does not continue on the following line), the following line should be at the same indentation level unless it closes a code or evaluation block as per normal indentation rules:
function Test-Function ($FullPath) {
if ($FullPath) {
# These lines have pipelines split over two lines. They indent as expected.
$Path = $FullPath |
Split-Path -Parent
$FileName = $FullPath |
Split-Path -Leaf
# These lines have full pipelines. Each removes an additional indentation.
$Path = $FullPath | Split-Path -Parent
$FileName = $FullPath | Split-Path -Leaf
$Path = $Path.Trim()
$FileName = $FileName.Trim()
return Join-Path $Path $FileName
}
}
Actual Behaviour
Each complete, single-line pipeline removes one indentation level for all lines following it, in addition to normal end-block un-indentation:
function Test-Function ($FullPath) {
if ($FullPath) {
# These lines have pipelines split over two lines. They indent as expected.
$Path = $FullPath |
Split-Path -Parent
$FileName = $FullPath |
Split-Path -Leaf
# These lines have full pipelines. Each removes an additional indentation.
$Path = $FullPath | Split-Path -Parent
$FileName = $FullPath | Split-Path -Leaf
$Path = $Path.Trim()
$FileName = $FileName.Trim()
return Join-Path $Path $FileName
}
}
Attached Logs
Logs will be send directly.
The text was updated successfully, but these errors were encountered:
Formatting in the PowerShell is provided by PSScriptAnalyzer.
This regression was identified and fixed in that project in PowerShell/PSScriptAnalyzer#1191. It will be available with the next PSScriptAnalzyer release, which should fix this problem when installed on your module path.
We actually deliberately set the default in the extension to lessen the impact of this regression.
I'm still seeing premature un-indentation when the pipeline includes script blocks like in the case of ForEach-Object.
I'll try to complain in the right direction: PowerShell/PSScriptAnalyzer#1032.
System Details
System Details Output
Issue Description
Setting powershell.codeFormatting.pipelineIndentationStyle to "IncreaseIndentationForFirstPipeline" or "IncreaseIndentationAfterEveryPipeline" causes every line after a single-line pipeline to be un-indented by an extra level. Setting the value to the default "NoIndentation" value, pipelines are ignored and indentation behaviour returns to that which was provided in the previous release of vscode-PowerShell.
Use this code for example:
Expected Behaviour
If a line contains a complete pipeline (i.e., one that does not continue on the following line), the following line should be at the same indentation level unless it closes a code or evaluation block as per normal indentation rules:
Actual Behaviour
Each complete, single-line pipeline removes one indentation level for all lines following it, in addition to normal end-block un-indentation:
Attached Logs
Logs will be send directly.
The text was updated successfully, but these errors were encountered: