-
Notifications
You must be signed in to change notification settings - Fork 513
Auto-complete comment help for functions #748
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
Conversation
That is incredibly cool! Does the |
It'd be nice if we could remove the selection of the text after it gets inserted. Even better if the cursor could be placed inside of the synopsis field (though I know it's probably not super easy). In the future it'd be nice to do this as a dynamic snippet so that you can tab through the fields to enter the new text. |
That would be cool and could replace the current |
Yes, I think removing the selection and putting the cursor in the synopsis field shouldn't be hard as we know the location of the synopsis relative to the trigger characters. But, I think tabbing through the fields without going through the snippet completion provider might be difficult. I am not sure if snippet provider has a default completion mode i.e. the user doesn't have to tab through the completion candidates, the editor just inserts the best match (a la |
You can provide default values for the snippet fields:
The user can confirm the defaults by hitting ESC I think. It looks like you can insert a snippet into the document without a completion provider, check out the
Might be doable! Only real challenge is inserting the snippet syntax into PSScriptAnalyzer's correction without it making the code nasty. |
wow! stay tuned for the snippet version then! 😃 |
Awesome! I think that'd make it pretty much perfect :) |
We will probably want to remove the current |
I think this functionality only appears if you type |
But what if my intent is to comment out the function? :-) In general, you can avoid snippet completion by pressing Esc or clicking away. |
In this case you'll get some really nice comment-based help to go with your commented-out function ;) We'll polish it up after the first iteration. |
Perfect! Does it work to cancel out of the property fields when you hit ESC? |
We will definitely polish the experience, but here is another workaround for the case when if someone just wants use |
By cancel out the property fields do you mean that the tabbing loses focus? |
Looking good. My only qualm is the |
I think we should leave it up to the user to choose between |
If we allow |
I also don't see the As far as the PSScriptAnalyzer rule is concerned, I'm fine with the user having an option there so that part of the code could definitely stay in. |
Good point. May be we just remove the |
Sounds good to me. |
Love it! This is awesome. |
How about if the snippet could work INSIDE the function? (a la https://technet.microsoft.com/en-us/library/hh500719.aspx: 'It’s preferable to include the help within the function rather than just before. That helps keep the comment "part" of the function, and ensures Windows PowerShell won’t confuse it for something else.'). Plus, I like it better :) |
@brsh Not everybody agrees with that placement (I sure don't). :-) That said, seems like it could be made to work in both locations. You probably prefer tabs over spaces and cuddled elses too, eh? ;-) Generally folks are going to have their "religious" viewpoint on how their code should be styled. And we try to accommodate. |
We're going to make it work both ways. PSScriptAnalyzer's rule which provides this behavior is capable of placing it both outside and inside of the function definition, we just need to expose it as an option in the extension. I've just filed issue #763 to track this for the next feature update. |
I agree with @brsh I also like to have my help within the function so when I collapse functions the help is also collapsed within the function. The Function Snippet in the ISE with help outside the function bothered me so much I created new Snippets to solve this ;-) |
Awesome guys! |
Woohoo! Thanks! I'm all for personal opinions (and for sometimes changing them: I'm coming around on spaces vs tabs), but it's great to have tools that can support them (and people who support those tools). This extension is what moved me over to vscode. It just keeps getting better, and I'm grateful! |
@daviwil I mean CmdletBinding in a file definition (ps1, psm1). |
The only issue with this is that to compress multi-line comments there has to be a space on each line of the multi-line comment. More of a bug with the extension I'd say though. |
@rbobot Are you referring to having this comment based auto-complete help for a script, not just limited to functions? That is my question anyway. |
@jkavanagh58, I always wrote comment based help for each script file and it would be convenient for me if this method worked not only for functions but also for the entire script. |
@rbobot agreed! I know this issue is "Auto-complete comment help for functions" but wondering why it would be limited to functions. |
Hey guys, here's the issue tracking that feature request: #769 |
Related PRs