Skip to content

SubExpression operator brokes lines indent #477

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
Miotis opened this issue Feb 1, 2017 · 1 comment
Closed

SubExpression operator brokes lines indent #477

Miotis opened this issue Feb 1, 2017 · 1 comment
Assignees
Labels
Issue-Bug A bug to squash.

Comments

@Miotis
Copy link

Miotis commented Feb 1, 2017

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"
  }
}
@daviwil
Copy link
Contributor

daviwil commented Feb 1, 2017

Interesting, thanks for the report! /cc @kapilmb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants