Skip to content

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

Closed

Description

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

Activity

  1. MartinGC94 commented on Mar 4, 2023

    @MartinGC94
    Contributor

    Yeah I broke it in one of my PRs. I've fixed it here: #18755 but it hasn't made its way into an official release yet. If I had to guess, preview 2 should have the fix.

  2. added and removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Mar 6, 2023
  3. ghost closed this as completedon Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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