Skip to content
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

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

Closed
wibblemonkey opened this issue Dec 16, 2016 · 1 comment
Closed

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

wibblemonkey opened this issue Dec 16, 2016 · 1 comment

Comments

@wibblemonkey
Copy link

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.

@daviwil
Copy link
Contributor

daviwil commented Dec 16, 2016

Thanks a lot Jim! I just fixed all the snippets, it'll go out with today's update to the extension!

daviwil added a commit that referenced this issue Dec 16, 2016
Fix #384: PowerShell snippets broken in VS Code 1.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants