-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Improve completion of parameters for attributes #14525
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
Improve completion of parameters for attributes #14525
Conversation
|
I'd expect follow works but it doesn't: function bar { [parameter(Position,<Tab> |
|
Agreed, that would be nice but I don't know how I would implement that. Do I update completionContext to also include the tokens? Do I parse the input again to get the tokens? Use regex to determine if the text looks like an attribute? |
Yes, it would be nice. I don't know if even that is possible (all we have is an ErrorAst). It would be a sad limitation. If so this could be addressed by prediction feature (not in the PR). |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs
Show resolved
Hide resolved
Definitely better in a separate PR. I don't have a total picture of how to achieve this, but:
I believe the current token is available here: PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs Lines 22 to 24 in c909541
and the full token array is available here: PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs Line 62 in c909541
It should be possible to search backward through the token array if need be. If the token up to that point isn't available, I don't think there's a way of piercing through the tokeniser abstraction to see the raw input currently, but the right way to do that would be to expose it as a token anyway. |
…letionAnalysis.cs Co-authored-by: Robert Holt <rjmholt@gmail.com>
|
@MartinGC94 Thanks for your contribution! |
|
🎉 Handy links: |
PR Summary
Fixes: #12771
Fixes issue where tab completion for attribute parameters only works for the first parameter due to the comma(s) required for the following parameters.
PR Context
If you are using an attribute like [Parameter()] you need to remember the full list of parameters because tab completion/intellisense doesn't work unless you are writing the first parameter.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.