Vscode-powershell: Possible powershell.codeFormatting.whitespaceAroundOperator bug

Created on 21 Mar 2018  路  3Comments  路  Source: PowerShell/vscode-powershell

Issue Description

Not sure if this is an actual bug or not, but consider this example when setting powershell.codeFormatting.whitespaceAroundOperator to true:

$numberOfDaysToSubtract = 10
(Get-Date).AddDays(-$numberOfDaysToSubtract)

When using the "auto-formatter", VSCode changes it to:

$numberOfDaysToSubtract = 10
(Get-Date).AddDays( - $numberOfDaysToSubtract)

Is that the expected behavior? It does work of course, but I've never seen it written like that ever, so wanted to confirm if it's intented.

Thanks!

Area-Code Formatting Issue-Bug

Most helpful comment

That seems like a bug to me. That rule should handle unary operators differently - as in enforcing no space between the operator and its target.

All 3 comments

That seems like a bug to me. That rule should handle unary operators differently - as in enforcing no space between the operator and its target.

@AWahlqvist

So this formatting actually comes from PSScriptAnalyzer. We just get the results from it and make the changes to the code.

Can you move this over to there so the folks that work on PSSA are aware?

Thanks @tylerl0706! I opened up an issue over at the PSSA repo instead!

See this bug in the PSSA repo:
https://github.com/PowerShell/PSScriptAnalyzer/issues/847

Was this page helpful?
0 / 5 - 0 ratings