Skip to content

SubExpression operator brokes lines indent #477

Closed
@Miotis

Description

@Miotis

System Details

  • Operating system name and version: Win8.1
  • VS Code version: 1.8.1
  • PowerShell extension version: 0.9.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.16394
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

Issue Description

Code auto formatting (Shift+Alt+F) works incorrect if it tries to format indents after any SubExpression operator $(expression) usage.
Note: It works correct if SubExpression is inside double quotes.

Example 1 (in param assigning):

function Expected
{
  param( $one = $(throw "Set var value check"),
    $two,
    $three
  )
  Write-Verbose "Some other code"
}

function Current
{
  param( $one = $(throw "Set var value check"),
  $two,
  $three
)
Write-Verbose "Some other code"
}

Example 2 (in code):

function AnotherCurrent
{
  if ($true)
  {
    if ($true)
    {
      Write-Verbose "Correct indent"
      $var = $(Get-FreeDriveLetter) + ":";
    Write-Verbose "Indent now broken"
  }
  $var = $(Get-FreeDriveLetter) + ":";
Write-Verbose "Indent now broken again"
}
}

function AnotherExpected
{
  if ($true)
  {
    if ($true)
    {
      Write-Verbose "Correct indent"
      $var = $(Get-FreeDriveLetter) + ":";
      Write-Verbose "Expected Indent"
    }
    $var = $(Get-FreeDriveLetter) + ":";
    Write-Verbose "Expected Indent"
  }
}

function AnotherForQuotedSubExpression
{
  if ($true)
  {
    if ($true)
    {
      Write-Verbose "Correct indent"
      $var = "$(Get-FreeDriveLetter):";
      Write-Verbose "Correct indent"
    }
    $var = "$(Get-FreeDriveLetter):";
    Write-Verbose "Correct indent"
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions