Skip to content

Possible powershell.codeFormatting.whitespaceAroundOperator bug #1237

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
AWahlqvist opened this issue Mar 21, 2018 · 3 comments
Closed

Possible powershell.codeFormatting.whitespaceAroundOperator bug #1237

AWahlqvist opened this issue Mar 21, 2018 · 3 comments
Labels

Comments

@AWahlqvist
Copy link

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!

@rkeithhill
Copy link
Contributor

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.

@TylerLeonhardt
Copy link
Member

@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?

@AWahlqvist
Copy link
Author

AWahlqvist commented Mar 26, 2018

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

See this bug in the PSSA repo:
PowerShell/PSScriptAnalyzer#847

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

No branches or pull requests

3 participants