Skip to content

Powershell snippets broken in latest VS Code release (1.8.0) #384

Closed
@wibblemonkey

Description

@wibblemonkey

System Details

  • Operating system name and version: Windows Server 2012 R2
Platform ServicePack Version    VersionString
-------- ----------- -------    -------------
 Win32NT             6.3.9600.0 Microsoft Windows NT 6.3.9600.0

VSCode Version 1.8.0

  • Commit 38746938a4ab94f2f57d9e1309c51fd6fb37553d
  • Date 2016-12-13T17:45:32.595Z
  • Shell 1.4.6
  • Renderer 53.0.2785.143
  • Node 6.5.0

PowerShell extension version: 0.7.2

Output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

The changes to snippets in the latest release of VS Code (1.8.0) have broken PowerShell snippets - the $ prefix on PowerShell variables is being stripped, unless the name of the PowerShell variable is a snippet variable.

Ex. 1 - works

    "Parameter": {
        "prefix": "parameter",
        "body": [
            "# ${Parameter help description}",
            "[Parameter(${AttributeValues})]",
            "[${ParameterType}]",
            "$${ParameterName}"
        ],
        "description": "Parameter declaration snippet"
    },
# Parameter help description
[Parameter(AttributeValues)]
[ParameterType]
$ParameterName

Ex. 2 - broken

    "Parameter-Path": {
        "prefix": "parameter-path",
        "body": [
            "# Specifies a path to one or more locations.",
            "[Parameter(Mandatory=$true,",
            "           Position=${Position:0},",
            "           ParameterSetName=\"${ParameterSetName:Path}\",",
            "           ValueFromPipeline=$true,",
            "           ValueFromPipelineByPropertyName=$true,",
            "           HelpMessage=\"Path to one or more locations.\")]",
            "[Alias(\"PSPath\")]",
            "[ValidateNotNullOrEmpty()]",
            "[string[]]",
            "$${ParameterName:Path}$0"
        ],
        "description": "Parameter declaration snippet for Path parameter that does not accept wildcards. Do not use with parameter-literalpath."
    },
        # Specifies a path to one or more locations.
        [Parameter(Mandatory=true,
                   Position=0,
                   ParameterSetName="Path",
                   ValueFromPipeline=true,
                   ValueFromPipelineByPropertyName=true,
                   HelpMessage="Path to one or more locations.")]
        [Alias("PSPath")]
        [ValidateNotNullOrEmpty()]
        [string[]]
        $Path

In this case the $Path variable is okay, but $true is rendered as true in the inserted snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions