Prerequisites
Steps to reproduce
Consider this example:
function Verb-Noun
{
Param
(
[Parameter(Position = 0)]
[string]
$Param1,
[Parameter(Position = 1)]
[System.Management.Automation.ActionPreference]
$Param2
)
}
Verb-Noun -Param1 Hello <Tab>
I would expect the tab completion to suggest values for Param2 because it's the first positional parameter that hasn't been bound to a named parameter and this is how the real parameter binder works. Unfortunately it doesn't work, it simply falls back to the file/directory suggestions.
The same issue occurs if you (presumably by mistake) try to start the positional parameters at 1 instead of 0:
function Verb-Noun
{
Param
(
[Parameter(Position = 1)]
[System.Management.Automation.ActionPreference]
$Param1
)
}
Verb-Noun <Tab>
As far as I can tell the issue is here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs#L1596 where it looks if the position for the parameter matches exactly the position the cursor is at.
Expected behavior
Tab completion should find the right parameter to offer completions for.
Actual behavior
It falls back to the generic file/directory completion
Error details
No response
Environment data
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.0-preview.5
PSEdition Core
GitCommitId 7.3.0-preview.5
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
Consider this example:
I would expect the tab completion to suggest values for Param2 because it's the first positional parameter that hasn't been bound to a named parameter and this is how the real parameter binder works. Unfortunately it doesn't work, it simply falls back to the file/directory suggestions.
The same issue occurs if you (presumably by mistake) try to start the positional parameters at 1 instead of 0:
As far as I can tell the issue is here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs#L1596 where it looks if the position for the parameter matches exactly the position the cursor is at.
Expected behavior
Tab completion should find the right parameter to offer completions for.Actual behavior
It falls back to the generic file/directory completionError details
No response
Environment data
Visuals
No response