Vscode-powershell: Reindent lines breaks here strings

Created on 25 Jul 2017  路  6Comments  路  Source: PowerShell/vscode-powershell

System Details

  • Operating system name and version: Windows Server 2016
  • VS Code version: 1.15.0-insider
  • PowerShell extension version: 1.4.1
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Reindent Lines breaks here-strings

After running Reindent Lines:

function get-test 
{
        write-host @"
        something    
        "@
}

This breaks there here-string as white space is not allowed before the string terminator (which the syntax highlighter correctly points out).
Also you do not usually want additional white space added in the middle of a literal string.
Possibly related to #961

Issue-Bug Resolution-External

All 6 comments

@kapilmb Does the "Reindent Lines" command use the code formatter?

Same experience for me. I need to remove the indent to make it work properly, which is not my preference when working in a block in which everything else is indented.

@Eisen-Hardt the ability for "@ to have spaces/tabs in front of it would actually be a PowerShell feature.

Can you open an issue here?

Today, a script wont work properly with anything in front of the closing here string ("@)

You know, I did just see the same thing in ISE and was thinking maybe this isn't a vscode thing. I will open an issue, thx.

Looks like there is one open already. https://github.com/PowerShell/PowerShell/issues/2337#issue-178501482

@TylerLeonhardt should this be closed as resolution-external or would there potentially be plans to intercept the indentation process and "smart indent" any detected here strings? Seems like that's fraught with issues vs. PowerShell/PowerShell#2337 (comment)

Was this page helpful?
0 / 5 - 0 ratings