Skip to content

powershell.codeFormatting.whitespaceBetweenParameters inappropriately removes + operators in string concatenation #1536

Closed
@wmassingham

Description

@wmassingham

Issue Description

When formatting a document with powershell.codeFormatting.whitespaceBetweenParameters enabled, the formatter inappropriately removes + operators in string concatenation.

Steps to reproduce:

  1. Enter this code example: Write-Output ($env:computername + ", " + $env:username) (GitHub is collapsing the whitespace, but there are four spaces on each side of each plus sign)
  2. Enable powershell.codeFormatting.whitespaceBetweenParameters
  3. Format document

Expected result:

Write-Output ($env:computername + ", " + $env:username)

Actual result:

Write-Output ($env:computername ", " + $env:username) (which is syntactically invalid!)

Additionally, if you start out with the expected result and format the document, you get the following result:

Write-Output ($env:computername ", " $env:username) ...which is even worse, as the operators have been removed entirely.

Attached Logs

1593619176-7b7e0c1b-7340-41cb-a9a0-c526c1c513bd1593619173652.zip
editor services.log

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.19041
VSCode 1.46.1
PowerShell Extension Version 2020.6.0

PowerShell Information

Name Value
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.19041.1
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
powershell ms-vscode 2020.6.0

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