Skip to content

Incorrect Multi-line Pipeline Indentation when inside a Scriptblock that also has a Pipeline #1680

Open
@ArchitektApx

Description

@ArchitektApx

System Details

Manjaro Linux:

### VSCode version: 1.56.2 054a9295330880ed74ceaedda236253b4f39a335 x64

### VSCode extensions:
aaron-bond.better-comments@2.1.0
eamodio.gitlens@11.4.1
GitHub.vscode-pull-request-github@0.26.0
ms-dotnettools.csharp@1.23.11
ms-vscode.mono-debug@0.16.2
ms-vscode.powershell@2021.2.2


### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.12.2-1-MANJARO PowerShell/vscode-powershell#1 SMP PREEMPT Fri May 7 17:53:15 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Windows 10 Enterprise:

### VSCode version: 1.56.2 054a9295330880ed74ceaedda236253b4f39a335 x64

### VSCode extensions:
aaron-bond.better-comments@2.1.0        
CoenraadS.bracket-pair-colorizer-2@0.2.0
eamodio.gitlens@11.4.1
GitHub.vscode-pull-request-github@0.26.0
Ludwig.wordcounter@0.0.1
ms-vscode-remote.remote-wsl@0.56.2      
ms-vscode.powershell@2021.2.2
ms-vscode.powershell-preview@2021.4.2
shd101wyy.markdown-preview-enhanced@0.5.18
tht13.html-preview-vscode@0.2.5
uctakeoff.vscode-counter@2.2.2


### PSES version: 2.4.1.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.19041.906
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.906
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

When using IncreaseIndentationForFirstPipeline or IncreaseIndentationAfterEveryPipeline as multiline pipeline indentation style the code is formatted inproperly when inside a Scriptblock which also has pipeline indents.
Examples are with IncreaseIndentationForFirstPipeline and show some Pseudo-Powershell.

Expected Behaviour

# if OTBS and IncreaseIndentationForFirstPipeline is selected this code won't be reformatted as it is already "correct"

$Test = $SomeValues | 
    Select-Object Some, Values | 
    Sort-Object -Property Values

if ($Test) {
    #Do stuff with test
}

# this should also be considered correct and not getting reformated 
Test-Scriptblock -Scriptblock {
    $Test = $SomeValues | 
        Select-Object Some, Values | 
        Sort-Object -Property Values
    
    if ($Test) {
        #Do stuff with test
    }
} -PassThru | 
    Run-Scriptblock

Actual Behaviour

# as expected nothing was reformatted 

$Test = $SomeValues | 
    Select-Object Some, Values | 
    Sort-Object -Property Values

if ($Test) {
    #Do stuff with test
}

# but here the indentiation does not stop at sort-object (..) but rather indents everything that follows too 
Test-Scriptblock -Scriptblock {
    $Test = $SomeValues | 
        Select-Object Some, Values | 
        Sort-Object -Property Values
    
        if ($Test) {
            #Do stuff with test
        }
    } -PassThru | 
        Run-Scriptblock

# with IncreaseIndentationAfterEveryPipeline the same incorrect indentation will be applied 
Test-Scriptblock -Scriptblock {
    $Test = $SomeValues | 
        Select-Object Some, Values | 
            Sort-Object -Property Values
    
            if ($Test) {
                #Do stuff with test
            }
        } -PassThru | 
            Run-Scriptblock

Attached Logs

  • No logs to attach -

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions