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
The
$fakeBoundParameterhashtable 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:
Then type "repro a1, btab". Then inspect
$fbp(which was set by the completer).Expected result:
The hashtable stored in
$fbpshould contain some $Keyword values, i.e.@{ 'Keyword' = @( 'a1', 'b' ) }.Actual result:
The hashtable stored in
$fbpis empty.Environment
Oh, I'm supposed to run a different script; not just $PSVersionTable: