Skip to content

Inserting help inside a function is broken #1509

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
ghost opened this issue Sep 1, 2018 · 8 comments
Closed

Inserting help inside a function is broken #1509

ghost opened this issue Sep 1, 2018 · 8 comments
Assignees
Labels
Issue-Bug A bug to squash.

Comments

@ghost
Copy link

ghost commented Sep 1, 2018

Using VS Code to write PowerShell scripts. When writing an Advance function I used to be able to type '##' (that's a double hash) at the top of the function between the function name and the [cmdletbinding()] and it would automatically add the PowerShell help descriptions.

Now when I do this it doesn't add the help but breaks all of my formatting.

I logged a previous bug report but was told this is fixed in the current version, #1493.

Still broken sorry. :(

Can someone please fix this awesome feature. Thanks!

Kind regards
Garry

System Details

Major Minor Build Revision


1 8 4 0

PSVersion 5.1.17134.228
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.228
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

@TylerLeonhardt
Copy link
Member

Thanks for the info! Can you also attach the logs here so we can get a better idea of what's going on?

@TylerLeonhardt
Copy link
Member

Also, if you could provide a screenschot and some sort of repro that'd be really appreciated!

@nlsdg
Copy link

nlsdg commented Sep 2, 2018

Same problem here. Logs and screenshots in the attached .zip.
1509_log.zip

Repo: create a new powershell file, paste the following and type ## on line 2. (Same as issue #1488.)

function Write-HelloWorld {
    
    [CmdletBinding(DefaultParameterSetName="Default")]
    param (
        $Hello,
        $World
    )
    Write-Host "$Hello $World"
}

It turns into this:

function Write-HelloWorld {
    #
    [CmdletBinding(DefaultParameterSetName="Default")]
    param (
    ,
    
    )
    Write-Host " "
    }
    [CmdletBinding(DefaultParameterSetName="Default")]
    param (
        $Hello,
        $World
    )
    Write-Host "$Hello $World"
}

@rjmholt
Copy link
Contributor

rjmholt commented Sep 3, 2018

I'm having some trouble reproducing this. Here's my current build of master branch (the fix commits being the same as the release):
functionsnippet

@rjmholt
Copy link
Contributor

rjmholt commented Sep 3, 2018

@ghost, @nlsdg can you try using the extension build attached and see if the error still occurs?

psvsix.zip

@DWOF
Copy link

DWOF commented Sep 3, 2018

@rjmholt I'm having the same issue. I have installed the extension build but still experience the incorrect behaviour.

1509.zip

I have also changed to the user version of the install but the issue persisted.

Function ExportFSAPI {
    
    Param(
        [Parameter(Mandatory = $True)][SecureString]$APIString,
        [Parameter(Mandatory = $True)][String]$APIPath
    )

    Write-Verbose "**START $($MyInvocation.MyCommand)**"
    Write-Verbose "Test $APIPath"
    if (!$APIString) {
        write-warning "No API supplied."
        return
    }
    elseif (!$(test-path $(Split-Path $APIPath))) {
        Write-Verbose "Creating $(Split-Path $APIPath)"
        new-item $(Split-Path $APiPath) -itemtype directory
    }
    Write-Verbose "Import APIstring and decrypting"
    ConvertFrom-SecureString $APIString | Out-file $APIPath

    Write-Verbose "**END $($MyInvocation.MyCommand)**"
}
Function ExportFSAPI {
    #
    Param(
    [Parameter(Mandatory = )][SecureString],
    [Parameter(Mandatory = )][String]
    )
    
    Write-Verbose "**START $(.MyCommand)**"
    Write-Verbose "Test "
    if (!) {
    write-warning "No API supplied."
    return
    }
    elseif (!$(test-path $(Split-Path ))) {
    Write-Verbose "Creating $(Split-Path )"
    new-item $(Split-Path ) -itemtype directory
    }
    Write-Verbose "Import APIstring and decrypting"
    ConvertFrom-SecureString  | Out-file 
    
    Write-Verbose "**END $(.MyCommand)**"
    }
    Param(
        [Parameter(Mandatory = $True)][SecureString]$APIString,
        [Parameter(Mandatory = $True)][String]$APIPath
    )

    Write-Verbose "**START $($MyInvocation.MyCommand)**"
    Write-Verbose "Test $APIPath"
    if (!$APIString) {
        write-warning "No API supplied."
        return
    }
    elseif (!$(test-path $(Split-Path $APIPath))) {
        Write-Verbose "Creating $(Split-Path $APIPath)"
        new-item $(Split-Path $APiPath) -itemtype directory
    }
    Write-Verbose "Import APIstring and decrypting"
    ConvertFrom-SecureString $APIString | Out-file $APIPath

    Write-Verbose "**END $($MyInvocation.MyCommand)**"
}

@garryoneill
Copy link

garryoneill commented Sep 3, 2018

When typing "##", this what happens in version 1.8.2 and below, help is added to the top of the function.
help_working

Now, since version 1.8.3 and above, this is what happens,
help_broken

@rkeithhill
Copy link
Contributor

Yup, I can repro. In 1.8.4 if you use ## before the function keyword, doc comment help completion works but it doesn't if you try to place the doc comments inside the function.

@rjmholt rjmholt changed the title Inserting help is broken Inserting underneath the function keyword help is broken Sep 3, 2018
@rjmholt rjmholt changed the title Inserting underneath the function keyword help is broken Inserting help underneath the function keyword is broken Sep 3, 2018
@rjmholt rjmholt self-assigned this Sep 3, 2018
@rjmholt rjmholt changed the title Inserting help underneath the function keyword is broken Inserting help inside a function is broken Sep 3, 2018
@rjmholt rjmholt added Issue-Bug A bug to squash. Area-Templating labels Sep 4, 2018
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

6 participants