You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tab completion confusion with common parameters #1265
First, the matcher finds 3 possible matches: -Wait, -WarningAction and -WarningVariable (which is normal).
There are 2 issues here:
The matcher finds an exact match so it autocompletes to it without cycling through other results (in this case alias wa is an exact match for parameter WarningAction). Is this intended behavior? Should Tab cycle through matches or simply complete an alias like it does now?
Even if the text doesn't match an exact alias, for example with Import-Module -ve (Tab expansion for cmdlet arguments prefers aliases #6150), the matcher will find 2 possible matches: -MinimumVersion and -Verbose, however, it will prefer parameters in the cmdlet over common parameters, and will effectively return -MinimumVersion as the only match since Verbose is a common parameter (same thing would happen for -Wait if wa wasn't an alias for WarningAction).
I doubt the second one is intended behavior, but digging through the code I think I'm too unfamiliar with the codebase to find a good solution. Hope this helps other people:
If you want to dig in, this occurs in CompletionCompleters.CompleteCommandParameter() -> PseudoParameterBinder.DoPseudoParameterBinding() -> PseudoParameterBinder.BindNamedParameters() -> MergedCommandParameterMetadata.GetMatchingParameter()
You can see there the aliases loop and then the logic to filter common parameters.
In the your first issue, even if an exact match is found, I would expect it to cycle through other possible matches. For the second, it should also all possible matches including common parameters.
Activity
Peter-Schneider commentedon Aug 25, 2016
The actual behavior of case 2 should be ok unless you are using the cmdletbinding attribute.
adamgauthier commentedon Jul 25, 2018
Additional information on this issue
First, the matcher finds 3 possible matches:
-Wait,-WarningActionand-WarningVariable(which is normal).There are 2 issues here:
The matcher finds an exact match so it autocompletes to it without cycling through other results (in this case alias
wais an exact match for parameterWarningAction). Is this intended behavior? Should Tab cycle through matches or simply complete an alias like it does now?Even if the text doesn't match an exact alias, for example with
Import-Module -ve(Tab expansion for cmdlet arguments prefers aliases #6150), the matcher will find 2 possible matches:-MinimumVersionand-Verbose, however, it will prefer parameters in the cmdlet over common parameters, and will effectively return-MinimumVersionas the only match sinceVerboseis a common parameter (same thing would happen for-Waitifwawasn't an alias forWarningAction).I doubt the second one is intended behavior, but digging through the code I think I'm too unfamiliar with the codebase to find a good solution. Hope this helps other people:
If you want to dig in, this occurs in
CompletionCompleters.CompleteCommandParameter()->PseudoParameterBinder.DoPseudoParameterBinding()->PseudoParameterBinder.BindNamedParameters()->MergedCommandParameterMetadata.GetMatchingParameter()You can see there the aliases loop and then the logic to filter common parameters.
SteveL-MSFT commentedon Jul 26, 2018
Adam Gauthier (@louistio) Thanks for the investigation details!
In the your first issue, even if an exact match is found, I would expect it to cycle through other possible matches. For the second, it should also all possible matches including common parameters.