Skip to content

Setting 'newLineAfterCloseBrace' not recognizing instances where a newline should not be added. #559

Closed
PowerShell/PSScriptAnalyzer
#741
@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

With the setting "powershell.codeFormatting.newLineAfterCloseBrace" set to true, the formatter changes this:

$obj = $data | Select-Object -Property @{
    Name       = 'PropertyName1'
    Expression = { $_.ThePropertyName1 }
}, @{
    Name       = 'PropertyName2'
    Expression = { $_.ThePropertyName2 }
}

to this:

$obj = $data | Select-Object -Property @{
    Name       = 'PropertyName1'
    Expression = { $_.ThePropertyName1 }
}
, @{
    Name       = 'PropertyName2'
    Expression = { $_.ThePropertyName2 }
}

and this:

$obj = $data | Select-Object -Property @{
    Name       = 'PropertyName1'
    Expression = { $_.ThePropertyName1 }
} -Unique

to this:

$obj = $data | Select-Object -Property @{
    Name       = 'PropertyName1'
    Expression = { $_.ThePropertyName1 }
}
-Unique

Is there a way to ignore the closing braces that have valid code behind it on the same line (in these cases a comma or a dash, but I expect there are other scenarios)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions