Skip to content

Possible formatting issue related to unary operators #948

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 26, 2018 · 2 comments
Closed

Possible formatting issue related to unary operators #948

AWahlqvist opened this issue Mar 26, 2018 · 2 comments

Comments

@AWahlqvist
Copy link

Issue Description

So I opened this bug at the VSCode repo:
PowerShell/vscode-powershell#1237

It's about unary operators that (from what I can tell), aren't handled correctly when formatting the code.

This:

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

Becomes this:

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

When formatting the code in VSCode with powershell.codeFormatting.whitespaceAroundOperator set to true.

I got a response from @tylerl0706 who clarified that this formatting actually comes from PSSA, which is why I created a bug here instead.

What do you think?

Thanks!

@bergmeister
Copy link
Collaborator

bergmeister commented Mar 26, 2018

Thanks for taking the time to report this issue. This is a duplicate of #847 and I believe it is by design because the setting whitespaceAroundOperator does exactly what it is supposed to do.
I can understand however that the resulting formatting is not desired in this case,
PSSA has 3 built in rule sets (Allman, etc.) that VSCode uses as well and I think the best solution would be to tweak them and to come up with a more refined ruleset that allows certain exceptions like this case.

@AWahlqvist
Copy link
Author

Yes, it does seem to be a duplicate, sorry, missed the other one. Will focus any discussions to that bug instead.

Thanks!

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

No branches or pull requests

2 participants