Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-Formatter loses one level of identation after chain with more than 2 commands and script blocks #1378

Open
joaoe opened this issue Dec 1, 2019 · 2 comments

Comments

@joaoe
Copy link

joaoe commented Dec 1, 2019

Steps to reproduce

Input script, formatted already as expected.

Function a {
    Function b {
        Get-Content blah | ? {
            $_ -match foo    
        } | Set-Content bleh

        $AnotherStatement = 1
    }

    Write-Host "hi"
    b
    exit 1
}

a

Expected behavior

The example above after formatted looks the same.

Actual behavior

After a chain of more than 2 commands which spans several lines, the formatter loses one level of indentation. Using $(...) triggers the same problem.

Function a {
    Function b {
        Get-Content blah | ? {
            $_ -match foo
        } | Set-Content bleh

    $AnotherStatement = 1
}

Write-Host "hi"
b
exit 1
}

a

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.15063.1805
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.1805
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.3
@bergmeister
Copy link
Collaborator

bergmeister commented Dec 1, 2019

Thanks for taking the time to report the issue.
Have you set the VS-Code setting powershell.codeFormatting.pipelineIndentationStyle to a non-default value (default is NoIndentation)?
I cannot reproduce with the default setup. For non-default values of this setting, I can reproduce using the currently release version of 1.18.3, but PR #1359 has fixed this case already (i.e. does not reproduce using a build of the master branch any more) therefore the next release should have this also fixed for non-default values.

@joaoe
Copy link
Author

joaoe commented Dec 1, 2019

I don't know how or where to change that value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants