Skip to content

Formatter does not obey some whitespace settings #2375

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
anttiah opened this issue Dec 18, 2019 · 10 comments
Closed

Formatter does not obey some whitespace settings #2375

anttiah opened this issue Dec 18, 2019 · 10 comments

Comments

@anttiah
Copy link

anttiah commented Dec 18, 2019

Issue Description

The powershell.codeFormatting.WhitespaceInsideBrace setting has no effect and formatter adds whitespaces regardless of its value.

This has been around since 2019.9.0. I was hoping it would get fixed in this release but it didn't.

AFAIK, this one has nothing to do with the pipeline indentation issues reported earlier and should not be treated as a duplicate of any of those.

Steps to reproduce

Set
"powershell.codeFormatting.WhitespaceInsideBrace": false

Type into the editor
& {0}

Format document (Alt + Shift + F)

Expected behaviour

& {0}
No whitespace gets added inside braces.

Actual, incorrect behavior

& { 0 }
Note the added whitespace after the { and before the }.

Environment data

vscode-powershell v2019.12.0

VS Code

Version: 1.41.0 (system setup)
Commit: 9579eda04fdb3a9bba2750f15193e5fafe16b959
Date: 2019-12-11T18:37:42.077Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18363

Notes

This is basically a duplicate of #2245 but it got closed with erroneous information before I found it and managed to comment.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 18, 2019
@SydneyhSmith
Copy link
Collaborator

@anttiah thanks for opening this issue and providing repo steps! I am having some trouble reproducing this issue after our latest release--it would be great to know what your settings.json looks like. It would also be helpful to know if you are using the PowerShell Extension or our preview version of the PowerShell Extension?

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Dec 18, 2019
@anttiah
Copy link
Author

anttiah commented Dec 18, 2019

Hi @SydneyhSmith thank you for your prompt response. I'm using release version:

vscode-powershell Release History
v2019.12.0
Thursday, December 12, 2019
PowerShellEditorServices
🐛 👮‍ PowerShellEditorServices #1102 - Add PSAvoidAssignmentToAutomaticVariable to the default set of PSSA rules. (Thanks @bergmeister!)
🐛 👮‍ vscode-PowerShell #2214 - Fix PipelineIndentationStyle configuration issue. (Thanks @bergmeister!)

Before my tests I deleted directories ~\.vscode and ~\AppData\Roaming\Code and installed just the vscode-powershell extension. The only item in my settings.json is the one mentioned in the repro steps.

HTH

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 18, 2019
@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Dec 19, 2019

Thanks for the additional information @anttiah I am able to reproduce this in our "stable" PowerShell extension but not in the PowerShell Preview extension...we recently published an update to our Preview Extension which has addressed a number of underlying architectural issues, would you mind giving it a try and letting us know if you are still hitting this issue? The good news is that we expect these changes to hit our "stable" PowerShell extension in our next release

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 19, 2019
@TylerLeonhardt
Copy link
Member

@bergmeister did we cherry pick this poorly again 😅

@anttiah
Copy link
Author

anttiah commented Dec 20, 2019

@SydneyhSmith Does not happen with the preview version.

Don't know if this is just a typo or cherry pick related but I noticed that preview version writes the powershell.codeFormatting.whitespaceInsideBrace line into settings.json with lower case w whereas release version writes it with upper case W -> powershell.codeFormatting.WhitespaceInsideBrace. Neither of the versions, relase or preview, accept the different casing produced by the other version.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 20, 2019
@ghost
Copy link

ghost commented Jan 3, 2020

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

@ghost ghost added the Resolution-Inactive Will close automatically. label Jan 3, 2020
@ghost ghost closed this as completed Jan 3, 2020
@anttiah
Copy link
Author

anttiah commented Jan 3, 2020

Issue is still occurring.

@TylerLeonhardt TylerLeonhardt reopened this Jan 3, 2020
@TylerLeonhardt TylerLeonhardt removed the Resolution-Inactive Will close automatically. label Jan 3, 2020
@bergmeister
Copy link
Contributor

I don't think it is a cherry picking problem, by quickly looking at the 2 PSES branches @TylerLeonhardt . @anttiah is right though that the preview extension changed the settings to start all with a lowercase (PR #1867) 9 months ago.

@bergmeister
Copy link
Contributor

bergmeister commented Jan 3, 2020

Ok, I've checked PSSA, which works fine ( Invoke-Formatter '$a={$b}' -Verbose -Settings @{IncludeRules=@('PSUseConsistentWhitespace'); Rules=@{'PSUseConsistentWhitespace'=@{Enable=$true; CheckInnerBrace=$true}}}).
Maybe it is a wiring issue again, I'll have a look again, yes it is. Will issue a PR soon

@TylerLeonhardt
Copy link
Member

Fixed in that PR ^

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

No branches or pull requests

4 participants