-
Notifications
You must be signed in to change notification settings - Fork 511
'<#' does not trigger insert of comment based help ('##' does) #1228
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
Comments
This happens to me at times but usually I'm glad it fails because most of those times I'm commenting out a function and the auto-expansion to a help template is really bothersome. |
Keith makes a good point. I love the ability to auto insert the help comments, especially with the parameter names already filled out. |
In addition to the '#' style being uglier the recommended style is to use '<#' block comments. |
So it seems that this a pretty opinionated feature. However, we have some conflicting experiences.
Based on this, I wonder if I can convince those that want a block comment snippet if we can change the trigger from That way, both parties have their experience. Thoughts? |
Happy with any particular shortcut. |
@tylerl0706 any reason to not make it a config option? Could be as simple as off= don't generate Default it to on, and people can tweak the config to suit their needs and wants. |
Slightly more ambiguous solution: Make the completion provider API available from PowerShell/C# (like was done with code lens and symbols). Then refactor the existing HelpCompletionProvider to implement that API and allow it to be removed/adjusted from PowerShell. |
I think the issue here is that the last update broke the way that it worked and typing The preferences are also a good discussion but something broke in the last update. |
@SeeminglyScience oh I see this is not just a snippet. Got it. Then you're right, completion provider should be available from PowerShell/C#. That way we can also do Btw everyone, there is a snippet for Please use that as a work around until this issue is fixed! |
The |
Exactly @brettmillerb - it used to work when then typing And as you mentioned above, it was more handy than a regular snippet, as it generated help for already declared parameters - something the snippet does not. Looking at HelpCompletion.ts it still appear to be setup as a trigger, but for whatever reason it does not work in the latest version. |
After Doing a bit of digging. It seems like the following is happening: when you type Taking a peek at what is happening in the 1: This causes the matcher to not match and thus not insert the generated help. |
Great find @GABeech! |
Would it be possible to create a Command Pallet action to trigger the generation of comment-based help. While we're at it, I would also recommend creating a Settings option for the default location of comment-based help. I'm sure people are very passionate about where the correct place is for that block of text. If I had a say in the matter, the default should be between the function name and the param block, if only to allow for better code collapsing. function Test-Function {
<#
.SYNOPSIS
Blah
#>
[CmdletBinding()]
param() |
OK, I found the culprit and unfortunately it is VSCode. In the file
Remove that last decl for Also, I'd really, really like to change the trigger char sequence from In VSCode I used to get the help completion when I just wanted to block comment out a function. I can easily change the trigger char seq to fix this but we will need to document it very visibly to get folks to change their behavior. To make this work I might have to change the If we decide not to change the trigger seqs then I'll definitely add a setting to turn off this feature to keep my sanity. :-) Thoughts? |
OK so using So one option would be to remove the |
Good find @rkeithhill. So the issue logged here comes from fixing issue microsoft/vscode#9799 in commit microsoft/vscode@2504d71. Personally I see limited benefit of auto-closing block comments. Typically I use block comments to comment out parts of the code I am working on, during development. When doing that, auto-closing the block comment is just annoying, as I will have to remove the auto inserted |
@csandfeld raises a very good point. Very rarely, if ever, do I ever want the block comment to be automatically closed. @rkeithhill if we kept in the autoClosingPair for |
The code as designed only works with two character triggers. BTW why does the PowerShell lang config file contain this auto-closing pair:
WTF? And C# has a bit better auto-closing def that at leasst puts a space in there:
So we should probably use this for PowerShell:
The bulk of the help comments I've seen and created use Block comment style. I'm really leaning towards a setting and a single trigger seq - |
I agree that Alternatively as it's technically a snippet can we not use |
@brettmillerb makes a good point, if we already have the advanced snippet I haven't explored that part of the code much, but that makes sense to me. Plus if the work is being done in PSES (which it should if it isn't), all the editors will get it for cheap. |
There is a difference. The help completion provider understands the AST of the function and creates boiler-plate text for each parameter. That is one (maybe the only) feature that folks really like. I think I'm going to create a PR with this change - BTW the help generation could be smarter and take into account |
The only drawback I see from not having Besides the trigger, maybe a "PowerShell: Insert comment based help" option could be added to the command palette? And if possible, also an option to update already generated help (usefull when parameters have changed). The suggested |
Personally, I wish the help generation would only kick in when I really ask for it. I dislike using I also never want help outside the function... Maybe it could trigger off a period... but only when it's as the first non-whitespace, non-comment character, within the first comment block in a script / script block / function... and there's no P.S. I definitely think they should have a space on the closing <#
{CursorHere}
#> Then, if I type |
Agreed on both points.
I know how you feel. I never want help inside the function... Years of doing C# doc comments has just burned in that mental pathway - permanently. :-) We should be able to get the VSCode folks to tweak that auto-closing declaration.
That's an interesting approach but would require a good bit of change to the PSES help completion code. |
Also wanted to chime in and say that having this setting set to null or empty string should turn off this setting completely. |
Changing this setting does require a reload window. Trigger sequence changed to just "##". Fix #1228
* Add poweshell.helpCompletion setting to control/disable feature Changing this setting does require a reload window. Trigger sequence changed to just "##". Fix #1228 * Rename triggerFinderLineComment field per PR review
System Details
Issue Description
Typing <# right above/below a function statement, no longer triggers insert of comment based help. Typing ## does work, but I like the block comment better for the comment based help.
See GIF for details:

Attached Logs
vscode-ps-logs.zip
The text was updated successfully, but these errors were encountered: