Skip to content

hashtable formatting error #1530

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
ghost opened this issue Jun 15, 2020 · 2 comments
Closed

hashtable formatting error #1530

ghost opened this issue Jun 15, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 15, 2020

i've got a new problem with powershell formatting.
i upgraded to [email protected] an hour or two before i noticed this problem.
it may have existed prior to the upgrade, but i never noticed it.
it's particularly scary because i didn't notice it for some time until my code started failing.

the attached zip has all the files described below plus a debug log.

the before .ps1 code is in hashtable-formatting_BEFORE.ps1

$AzureAD = (Get-Command -FullyQualifiedModule @{ModuleName = 'AzureAD'; ModuleVersion = '2.0.2.76' }).Name 
$AzureADPreview = (Get-Command -FullyQualifiedModule @{ModuleName = 'AzureADPreview'; ModuleVersion = '2.0.2.102' }).Name

and the after .ps1 code is in hashtable-formatting_AFTER.ps1

$AzureAD = (Get-Command -FullyQualifiedModule @{ModuleName = '2.0.2.76' }).Name 
$AzureADPreview = (Get-Command -FullyQualifiedModule @{ModuleName 'AzureADPreview'; ModuleVersion '2.0.2.102' }).Name

i tried to reproduce the problem in unaffected-hashtables.ps1 but the code here formatted correctly.
i can't explain why.

i duplicated this problem on two machines. the details are in machine-details.txt.

here's the interesting part:

machine 2 is basically win10 winver 2004 with vscode ootb plus [email protected].
on machine 2, hashtable-formatting_BEFORE.ps1 formatted correctly.
then i copied my settings.json from machine 1 (win8.1) to machine 2.
when i reformatted hashtable-formatting_BEFORE.ps1 with the new settings.json, i got hashtable-formatting_AFTER.ps1.

so take a look at settings.json.

thanks folks

powershell-preview-hashtable-format-error.zip

@SydneyhSmith SydneyhSmith transferred this issue from PowerShell/vscode-powershell Jun 16, 2020
@ghost ghost added the Needs: Triage 🔍 label Jun 16, 2020
@bergmeister
Copy link
Collaborator

@elrod-johnson Thank you for taking the time to provide details. This is very likely caused by your setting powershell.codeFormatting.whitespaceBetweenParameters being set to true. This is a new setting that we recently added and its default is false. This issue has already been fixed as part of #1498 but is pending a patch release of PSScriptAnalyzer, which we plan to do in the next few weeks. In the meantime we suggest to set the setting value to its default value of false.
FYI @rjmholt @JamesWTruher @SydneyhSmith

@ghost
Copy link
Author

ghost commented Jun 18, 2020

that seems to have fixed it.
thank you

@ghost ghost closed this as completed Jun 25, 2020
This issue was closed.
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

1 participant