-
Notifications
You must be signed in to change notification settings - Fork 512
Double Hash (##) Trigger #1220
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
I just noticed this myself. I actually just discovered it accidentally but can't find ANY docs pertaining to it. It's not even listed in the snippet reference: https://github.com/PowerShell/vscode-powershell/blob/master/snippets/PowerShell.json#L536-L555 No sure if this is happening for anyone else but, for me, it only happens if I use a double hash ( ## ) either at the FIRST line after a function declaration or at the FIRST line above a function declaration: ##############################
#.SYNOPSIS
#Short description
#
#.DESCRIPTION
#Long description
#
#.EXAMPLE
#An example
#
#.NOTES
#General notes
##############################
function My-Function {
##############################
#.SYNOPSIS
#
#
#.DESCRIPTION
#Long description
#
#.EXAMPLE
#An example
#
#.NOTES
#General notes
##############################
[CmdletBinding()]
param (
)
begin {
}
process {
}
end {
}
}
There tends to also be a slight delay sometimes where, if I start typing, the snippet isn't automatically injected. So maybe a quick workaround is to make sure you create a space between your comment and the function declaration. |
Seems to happen at the last line of a function too... If I create my function with three empty lines, I can successfully put the double-hash in the middle one without the trigger taking place. Will be an alright workaround for now. The "offending" code is located in at line 117 of HelpCompletion.ts - at least this is where the trigger is defined. |
@theznerd Good find! I guess it's not considered a snippet then. |
Yeah so this is more powerful than a snippet. It will scan your function and add parameter comments and such to the help. You're right, we need to document this better. Feel free to open an issue to write a doc (or contribute if you'd like! 😃) Just an FYI... We're considering doing some abstractions to allow folks to register their own Editor completions - this will also give folks the ability to remove built in ones so if you like Thanks for filing this! |
The issue I have with this is that it is occurring in non-PowerShell files. The "snippet" (for lack of better term) is triggering within a JavaScript file. Could you please limit the triggering of this (and other PowerShell specific actions) to only PowerShell specific file types? VSCode PowerShell extension version: v2020.6.0 |
Can you share a JS file snippet of where you're seeing this? |
Sorry for the delay; too much work ;) Here is the snippet which I'm able to reproduce the issue. The behavior is variable depending on where comment blocks or perhaps any other lines of code are. I provided comments in the code snippet to indicate where I was able to type ## and repro the issue. There are other permutations, but this will hopefully give you what you need. You must have this code in a persisted file rather than an untitled window. function foo() {
//asdf
//Add 2 hashes above this comment, below this comment, within the console.log, anywhere between the main function defintion and the first sub-function definition. Having two comments before the function causes the issue not to occur. Must have an empty line either before this comment or after.
console.log("")
function bar() {
//Happens here too above or on the same line as this comment, but not below. But if you add a comment above or below, the behavior changes.
}
//No issue
console.log("##")
//This function definition does not need to be here for the issue to occur.
function baz() {
}
} |
Thanks @samusstrike we are having a bit of trouble reproducing this...it would be great to see a screenshot or GIF of your whole vscode screen...in particular it would be great to confirm the file type that it is opened as in vscode--thanks! |
Here are the steps to reproduce with more specificity. One thing to keep in mind is that you have to wait until the PowerShell extension has loaded to some degree so that it will start triggering the "## snippet". If you have VSCode open already and have opened a PowerShell file type for some time, then it should trigger right away. Steps:
Startup after completing step 4: Issue Illustration: The JavaScript snippet was listed in a previous comment. Here it is again to keep the entire repro in one place: function foo() {
//asdf
//Add 2 hashes above this comment, below this comment, within the console.log, anywhere between the main function defintion and the first sub-function definition. Having two comments before the function causes the issue not to occur. Must have an empty line either before this comment or after.
console.log("")
function bar() {
//Happens here too above or on the same line as this comment, but not below. But if you add a comment above or below, the behavior changes.
}
//No issue
console.log("##")
//This function definition does not need to be here for the issue to occur.
function baz() {
}
} |
Thanks @samusstrike for the detailed info, we were able to get this to reproduce. It looks like we do not have a filter in place for this feature to only run on PowerShell files. We are currently looking into the fix--thanks! |
Is there a way to disable the double hash trigger that adds single line comment blocks inside of functions aside from forking and removing the trigger myself? I'd prefer to just use the comment block "<#" trigger and leave my ability to comment out sections of my code using multiple hash marks (e.g. ###### BEGIN USER EDITABLE SECTION ######)
The text was updated successfully, but these errors were encountered: