Closed powercode closed 8 years ago
Check if you are not using New-CompletionResult in your code. Register-ArgumentCompleter is now cmdlet and won't work with this function (that is private to TabExpansion++ module).
For example, to get VM Name completed in Hyper-V module you'd have to:
$list = (Get-Command -Module Hyper-V -Noun VM).Name
Register-ArgumentCompleter -CommandName $list -ParameterName Name -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$optionalCn = @{}
$cn = $fakeBoundParameter["ComputerName"]
if($cn)
{
$optionalCn.ComputerName = $cn
}
Hyper-V\Get-VM -Name "$wordToComplete*" @optionalCn |
Sort-Object |
ForEach-Object {
$toolTip = "State: $($_.State) Status: $($_.Status)"
[System.Management.Automation.CompletionResult]::new(
$_.Name,
$_.Name,
'ParameterValue',
$toolTip
)
}
}
As you can see I'm using [ComletionResult] constructor. AFAIK this is the only way in this release. I hope to see some friendly command to that in the next one TBH. ;)
@powercode @bielawb I am having the same problem with this. I just installed TabExpansion++ on Windows 10 Build 10130, ran Get-ArgumentCompleter
, and have no results.
Cheers, Trevor Sullivan Microsoft MVP: PowerShell
This is a known issue - the ArgumentCompleter attribute in TabExpansion++ is colliding with the attribute in WMF5.
I will be removing the attribute based registration mechanism in TabExpansion++ because:
I wrote a script to convert existing completers, you can see it here: https://gist.github.com/lzybkr/0329f3346730c6135121
I think I'm mostly done fixing TabExpansion++, I just haven't found the time to test the changes thoroughly.
@lzybkr I tried to run the conversion script against the TabExpansion++ module directory, and received the following exceptions. Are there any specific requirements to run the conversion script? Should I copy the argument completer scripts to a new, empty folder? Perhaps the script is barfing on the non-PowerShell files in the module directory?
Cheers, Trevor Sullivan Microsoft MVP: PowerShell
Hmm, yeah, just run it on ps1 files. I know I ran it on *.ArgumentCompleters.ps1 and inspected some of results and it looked good.
@lzybkr I think I see the problem. I was not pipelining objects into it. Looks like it doesn't support passing in a folder path.
Closing as this is probably a non-issue now - folks have probably already converted to support WMF5 and the latest TabExpansionPlusPlus on the PowerShell gallery.
I don't get any custom completion working at all, whether I use tabexpansion++ or the built-in Register-ArgumentCompleter.
Know issue or supid user error?