Skip to content

PipelineIndentationStyle: When set to other settings other than NoIndentation: Edge case: Incorrect indentation due to backtick #1311

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

Closed
bergmeister opened this issue Aug 17, 2019 · 0 comments · Fixed by #1312

Comments

@bergmeister
Copy link
Collaborator

bergmeister commented Aug 17, 2019

Extracted from this comment of @mrboring : #1032 (comment)
This happens still on master even due to the recent fix for recognizing single line pipelines.

The following code results in a PSUseConsistentIndentation problem. It refers to the second from last closing brace:

Describe -Name 'Test' -Fixture {
    It -Name 'Test' -Test {
        {1 / 0 -or `
                2 / 0} | Should throw
    }
}

If I format the document using Shift+Alt+F I get:

Describe -Name 'Test' -Fixture {
    It -Name 'Test' -Test {
        {1 / 0 -or `
                2 / 0} | Should throw
}
}

Notice that the second from last closing brace has been unindented.

Strangely, if I move the Should throw to a new line, and format the document, the PSUseConsistentIndentation problem goes away:

Describe -Name 'Test' -Fixture {
    It -Name 'Test' -Test {
        {1 / 0 -or `
                2 / 0} |
            Should throw
    }
}

VS Code

Version: 1.36.1 (user setup)
Commit: 2213894ea0415ee8c85c5eea0d0ff81ecc191529
Date: 2019-07-08T22:59:35.033Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

Installed Extensions for VS Code

alefragnani.Bookmarks
Damien.autoit
eamodio.gitlens
ms-vscode.csharp
ms-vscode.powershell
ms-vscode.powershell-preview
streetsidesoftware.code-spell-checker
vscode-icons-team.vscode-icons

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
OS                             Microsoft Windows 10.0.18362 
Platform                       Win32NT
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.18.1
1.18.0
1.18.0

Various Settings Files

settings.json
PSScriptAnalyzerSettings.psd1
CustomRule.psm1

Various configuration files.zip

Originally posted by @mrboring in #1032 (comment)

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