Skip to content

Code Formatting : Whitespacing one line hashtable #1113

Open
@noupii

Description

@noupii

Hello
I am looking for a improvment on the current formatting tools by adding a whitespace after open bracket and before closing non empty curly brackets like :

#Actual
$emptyHash = @{ }               # an empty Hash
$myHash = @{foo = "bar"}

#Expected
$emptyHash = @{}                # an empty Hash
$myHash = @{ foo = "bar" } #whitespace after `{ `and before ` }`

Additional information:

  • I use the PowerShell extension on VS Code to format automaticaly my code on save.

  • My settings.json file:

{
    "editor.formatOnSave": true,
    "powershell.codeFormatting.preset": "Custom",
    "powershell.codeFormatting.alignPropertyValuePairs": true,
    "powershell.codeFormatting.ignoreOneLineBlock": false,
    "powershell.codeFormatting.newLineAfterCloseBrace": true,
    "powershell.codeFormatting.newLineAfterOpenBrace": true,
    "powershell.codeFormatting.openBraceOnSameLine": false,
    "powershell.codeFormatting.whitespaceAfterSeparator": true,
    "powershell.codeFormatting.whitespaceAroundOperator": true,
    "powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
    "powershell.codeFormatting.whitespaceBeforeOpenParen": true,
    "powershell.scriptAnalysis.enable": true,
    "files.trimTrailingWhitespace": true,
}

This feature exist on other language :
microsoft/TypeScript#9613 (comment)

Regards,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions