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

### snippet to auto generate DOCs for a cmdlet fails. #1488

Closed
Mark-Foresta opened this issue Aug 17, 2018 · 8 comments · Fixed by PowerShell/PowerShellEditorServices#726
Closed
Labels

Comments

@Mark-Foresta
Copy link

System Details

  • Operating system name and version:
    Windows 10

  • VS Code version:
    Version: 1.25.1
    Commit: 1dfc5e557209371715f655691b1235b6b26a06be
    Date: 2018-07-11T15:43:11.471Z
    Electron: 1.7.12
    Chrome: 58.0.3029.110
    Node.js: 7.9.0
    V8: 5.8.283.38
    Architecture: ia32

  • PowerShell extension version: 1.8.3

  • Output from $PSVersionTable:
    PS C:\Users\Administrator> $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

Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable

Issue Description

I am experiencing a problem with the ### snippet. This usually places a commented section for my CMDLet with Synopsis description and such. I believe in 1.8.3 there is a new error causing this to Fail. My output now is an odd left aligned version of all my code. I have recreated the problem with a simple Hello World function. The bottom half is what I wrote everything above it is the output of the snippet generator.

function Write-HelloWorld {
[CmdletBinding(DefaultParameterSetName="Default")]
param (
,

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

Attached Logs

Follow the instructions in the README
about capturing and sending logs.

@rjmholt
Copy link
Contributor

rjmholt commented Aug 17, 2018

Hi @Mark-Foresta, would you be able to attach any relevant logs? The instructions are in the README link at the bottom of your issue description

@Mark-Foresta
Copy link
Author

IssuesFor1488.zip

@Mark-Foresta
Copy link
Author

I think I have attached them

@rkeithhill
Copy link
Contributor

It repros for me so that should help in tracking it down.

@rjmholt rjmholt added Issue-Bug A bug to squash. Area-Snippets labels Aug 17, 2018
@rjmholt
Copy link
Contributor

rjmholt commented Aug 17, 2018

Problem seems to occur here:

public complete(): Thenable<void> {
if (this.langClient === undefined) {
return;
}
const change = this.lastChangeText;
const triggerStartPos = this.lastChangeRange.start;
const triggerEndPos = this.lastChangeRange.end;
const doc = this.lastDocument;
return this.langClient.sendRequest(
CommentHelpRequestType,
{
documentUri: doc.uri.toString(),
triggerPosition: triggerStartPos,
blockComment: this.settings.helpCompletion === Settings.HelpCompletion.BlockComment,
}).then((result) => {
if (result == null || result.content == null) {
return;
}
// todo add indentation level to the help content
const editor = window.activeTextEditor;
const replaceRange = new Range(triggerStartPos.translate(0, -1), triggerStartPos.translate(0, 1));
// Trim leading whitespace (used by the rule for indentation) as VSCode takes care of the indentation.
// Trim the last empty line and join the strings.
const text = result.content.map((x) => x.trimLeft()).slice(0, -1).join(this.getEOL(doc.eol));
editor.insertSnippet(new SnippetString(text), replaceRange);
});
}

First off it looks like we can't rely on VSCode for indentation as we used to?

@rjmholt
Copy link
Contributor

rjmholt commented Aug 17, 2018

Nothing has touched that code in several months though

@rjmholt
Copy link
Contributor

rjmholt commented Aug 17, 2018

It looks like we are passing the variable names through correctly, but VSCode is now doing something weird with them???

@rjmholt
Copy link
Contributor

rjmholt commented Aug 17, 2018

Ok, I've opened a PR with the fix.

None of that explains VSCode's mysterious behaviour btw, the bug was elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants