-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Fix positional argument completion #17796
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
Merged
daxian-dbw
merged 7 commits into
PowerShell:master
from
MartinGC94:FixPositionalArgumentCompletion
Aug 22, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6a162f6
Fix positional argument completion
MartinGC94 b8f20b8
Merge branch 'master' into FixPositionalArgumentCompletion
MartinGC94 5f4ace3
Fix merge conflict
MartinGC94 25e2f9b
Update src/System.Management.Automation/engine/CommandCompletion/Comp…
MartinGC94 0e9d688
Minor update to a comment
daxian-dbw 54d073a
Merge branch 'PowerShell:master' into FixPositionalArgumentCompletion
MartinGC94 ee31af5
Merge branch 'PowerShell:master' into FixPositionalArgumentCompletion
MartinGC94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What about more complex test like (expect Value3 in parameter position 3)
Verb-Noun -ParamPos0 Value0 ParamPos1Value1 -ParamPos2 Value2 ^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.
Is it necessary? The logic would be the same as in the previous test: It takes the next available positional parameter. It doesn't really matter if it's the first, third or even the 30th parameter position it's looking for.
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.
The code is too big to observe its logic in its entirety, and the test I'm asking about is a case I thought it might not work.
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.
That's fair. Here's how it works: The target position is found elsewhere and is based on how many positionally bound parameters have been specified, in the above example it would look for the second positional parameter (position 1) because one other positional parameter has been found.
The loop I've modified loops over the unbound parameters and parametersets that are valid based on the currently bound parameters, here it looks for any positional parameters with a position greater than or equal to the target location. It then saves whichever parameter has the lowest position and binds the argument to that.
Because it's looping over unbound parameters all the previous parameters "ParamPos0", "ParamPos1" and "ParamPos2" are automatically filtered out so the next available parameter would be "ParamPos3".