-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add quote handling in Verb, StrictModeVersion, Scope & PropertyType Argument Completers with single helper method #24839
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
Add quote handling in Verb, StrictModeVersion, Scope & PropertyType Argument Completers with single helper method #24839
Conversation
…rgument completers
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@MartinGC94 Could you please review? |
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Outdated
Show resolved
Hide resolved
|
I think the remaining mystery is with Array parameter completion. if you do But if you have an array and you surround quotes on the next item it does not tab complete correctly e.g. @MartinGC94 @iSazonov Wondering if you would know why this might be happening? |
src/Microsoft.PowerShell.Commands.Management/commands/management/NewPropertyCommand.cs
Outdated
Show resolved
Hide resolved
Yes, I suggest postpone this to follow PR. |
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
df404c8 to
593ccf5
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
MartinGC94
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine just a few suggestions. I didn't bother to look at the tests and verbs completion though.
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/ScopeArgumentCompleter.cs
Show resolved
Hide resolved
53fd566 to
a297ab8
Compare
00ebd15 to
a246416
Compare
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArmaanMcleod Now the PR contains too many unrelated changes (style, bug fixes, enhancements). Our guideline requires not mixing. I'd prefer to split the PR: first with bug fix, then style/refactoring with minimal changes in GetMatchingResults() for minimal completers, then enhancement GetMatchingResults().
Also we could update s_charactersRequiringQuotes with SearchValues.Create() in a PR.
src/System.Management.Automation/engine/CommandCompletion/ScopeArgumentCompleter.cs
Outdated
Show resolved
Hide resolved
It's a valid concern, as per your feedback I have reverted the changes. I will create follow up PRs to address these separately:
@MartinGC94 Thank you again for your review, I will address these in a separate PR so this one is easy to review and get merged in. I would also like to get these tested as well which will be easier in a separate PR With that said, @iSazonov are you ok with current changes as they stand to get this merged in? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@iSazonov Was there anything else you wanted me to address? I'd like to use this code to address #24873 as well. Let me know if there are concerns or we need MSFT team to approve these changes as well 🙂. I don't have anything else to add since there is no regression being introduced with these changes. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Is there any specific reason for not making the new method public? Afaik, there's still no built-in way to correctly handle quoting in third-party completers, and this should mostly solve that problem, right? Nevertheless, big 👍 for creating the method in the first place, having to handle quoting separately for each completer is really annoying. :) |
@MatejKafka I guess for now it should probably remain internal until it is finalised. I do agree it makes things a lot easier for managing quoting. There were some concerns around escaping which should probably be addressed before making this public. I also think the method argument itself probably needs to be tweaked for public use. Not sure how I feel making users use Happy for you to raise an issue and we can discuss way forward. @iSazonov @MartinGC94 thoughts? |
Right. |
PR Summary
The below argument completers don't have support for quotes:
VerbArgumentCompleterStrictModeVersionArgumentCompleterScopeArgumentCompleterThis PR creates a static method
GetMatchingResultswhich wraps the quote handling usingCompletionCompleters.HandleDoubleAndSingleQuoteand reuses this method across all these argument completers so quotes are handled in the same way. Happy to change this method name, I could not figure out a nicer name :D.I also refactored
VerbArgumentCompleterforGet-Verb/Get-Commandto separate the actual cmdlet filtering and the completion methods, so it can also use this shared method like the other completers. Previously the cmdlet filtering and completion code were quite coupled but it makes more sense to separate these two since they both have different requirements, and it simplifies the code.There are also more tests added to ensure single/double quotes are being handled correctly.
I've also ensured the
PropertyTypeArgumentCompleteris using the same method which was already handling quotes in #21117.PR Context
Fixes #24838
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.- [ ] Issue filed:
(which runs in a different PS Host).