Skip to content

Would like to get positionally-bound arguments in $fakeBoundParameter #14345

@jazzdelightsme

Description

@jazzdelightsme

The $fakeBoundParameter hashtable passed to argument completers sometimes comes in handy for calculating proper tab completion. But it is missing information about what is often the "most important" parameter--a parameter that is bound by position (or ValueFromRemainingArguments).

Repro steps:

Prep: load up the following:

function repro
{
    [CmdletBinding()]
    param( [Parameter(Position = 0, ValueFromRemainingArguments = $true)]
           [SupportsWildcards()]
           [string[]] $Keyword,

           [string[]] $MoreThings,

           [switch]$Force
         )
    try
    {
    }
    finally { }
}

Register-ArgumentCompleter -CommandName 'repro' `
                           -ParameterName 'Keyword' `
                           -ScriptBlock {
    param($commandName, $parameterName, $stringMatch, $commandAst, $fakeBoundParameter)

    $global:fbp = $fakeBoundParameter

    return @( 'a1', 'a2', 'b1', 'b2' )
}

Then type "repro a1, btab". Then inspect $fbp (which was set by the completer).

Expected result:
The hashtable stored in $fbp should contain some $Keyword values, i.e. @{ 'Keyword' = @( 'a1', 'b' ) }.

Actual result:
The hashtable stored in $fbp is empty.

Environment

Oh, I'm supposed to run a different script; not just $PSVersionTable:

PS version: 7.1.0
PropertyNotFoundException:
Line |
  17 |      $v = $m.Version; $pre = $m.PrivateData.PSData.Prerelease
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'PSData' cannot be found on this object. Verify that the property exists.
PSReadline version: 2.1.0
os: 10.0.20274.1001 (WinBuild.160101.0800)
PS file version: 7.1.0.0
HostName: ConsoleHost
BufferWidth: 237
BufferHeight: 9999

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions