Closed jazzdelightsme closed 11 years ago
Thanks for tracking down the problem.
The proposed fix isn't quite right - I think it breaks 2 scenarios:
I'm happy to fix the bug if you prefer.
Hmm... will it break those scenarios, or are they already broken? Without the change, the errors that show up in $error are like this:
Register-ArgumentCompleter : Cannot bind argument to parameter 'CommandName' because it is null.
At C:\Projects\DbgShell\DbgShell\bin\Debug\x86\TabExpansion++\TabExpansion++.psm1:675 char:40
+ Register-ArgumentCompleter @parameters
+ ~~~~~~~~~~~
So if it can't bind the param, it doesn't end up calling Register-ArgumentCompleter in those cases at all, right? (or does it?)
Oh... maybe you're saying that we should supply an empty string for the CommandName? Which could be done by adding $parameters[ 'CommandName' ] = @( '' ). But would it be weird, or a pessimization, to have completers for commands you don't have?
CommandName doesn't need to be specified, e.g.:
Register-ArgumentCompleter -ParameterName FooBar -ScriptBlock {
New-CompletionResult -CompletionText Zoo
}
function zed($FooBar) {}
zed -FooBar <TAB>
I tried a quick repro by taking one of the Hyper-V completers and changing the module name. I didn't see any errors in $error. The completer is also not registered, which I think is a good thing, but the background processing makes it hard to figure out why, in the case of a typo for example, nothing was registered.
Never mind - user error. I found a repro and found a better fix, now committed.
Thanks!
This is the thing that is always populating my $Error with stuff, because I don't have the Hyper-V module installed.