Skip to content

Formatter issues with indenting when brace and paren present on same line #558

Closed
@jasnic02

Description

@jasnic02

System Details

  • Operating system name and version: Windows 10 Pro
  • VS Code version: 1.10.2
  • PowerShell extension version: 0.10
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.14393.953
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.953
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Each open brace or paren on the same line is being counted as in indent trigger resulting in too many indents. ValidateScript is the best example:

    param (
        [Parameter(Mandatory, Position = 0, ValueFromPipeline)]
        [ValidateScript({
            if ($_ -is [System.IO.FileInfo] -or $_ -is [string]) {
                if ([System.IO.Path]::GetExtension($_) -ne '.xml' -and [System.IO.Path]::GetExtension($_) -ne '.gz') {
                    throw 'Invalid file extension specified for the InputObject parameter.'
                }
            }
            else {
                throw 'Invalid input object specified.'
            }

            $true
        })]
        [Object[]]$InputObject
    )

becomes:

    param (
        [Parameter(Mandatory, Position = 0, ValueFromPipeline)]
        [ValidateScript({
                    if ($_ -is [System.IO.FileInfo] -or $_ -is [string]) {
                        if ([System.IO.Path]::GetExtension($_) -ne '.xml' -and [System.IO.Path]::GetExtension($_) -ne '.gz') {
                            throw 'Invalid file extension specified for the InputObject parameter.'
                        }
                    }
                    else {
                        throw 'Invalid input object specified.'
                    }

                    $true
            })]
        [Object[]]$InputObject
    )

Note the closing '})]' is also indented. I believe the brace/paren characters should only be counted once for indent calculations if they are on the same line?

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