Skip to content

Positional argument autocompletion is broken in 7.4.1-preview.1 when multiple parameter sets have a positional parameter #19279

@MatejKafka

Description

@MatejKafka

Steps to reproduce

function fn {
    [CmdletBinding(DefaultParameterSetName = "A")]
    param(
            [Parameter(Mandatory, Position = 0, ParameterSetName = "B")]
            [Hashtable]
        $B,
            [Parameter(Mandatory, Position = 0, ParameterSetName = "A")]
            [ArgumentCompleter({"test"})]
            [string]
        $A
    )
}

Now type fn in the prompt and press the Tab key.

Expected behavior

In PowerShell 7.3.3 and and earlier versions, the argument completer for $A is invoked and the command is autocompleted to fn test, because $A is the only parameter with Position=0 and a compatible type.

Actual behavior

In PowerShell 4.1.0-preview.1, the argument completer for $A is not invoked, and the generic path autocompletion appears instead. However, when the input is changed to fn t and then Tab is pressed, the completer is correctly invoked and completes the input to fn test.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.1
PSEdition                      Core
GitCommitId                    7.4.0-preview.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions