Closed Aankhen closed 2 years ago
Thank you for the bug report.
Can you print out the value of $error
? I'd like to see the stack traceback where CompleteInput
is being called.
Sure, here you go:
C:\Users\A> k get pod asdasdAn exception occurred in custom key handler, see $error for more information: Exception call
C:\Users\A> $error
MethodInvocationException: Exception calling "CompleteInput" with "3" argument(s): "Cannot process argument because the value of argument
"completionText" is null. Change the value of argument "completionText" to a non-null value."
MethodInvocationException: Exception calling "CompleteInput" with "3" argument(s): "Cannot process argument because the value of argument
"completionText" is null. Change the value of argument "completionText" to a non-null value."
Apologies it took so long to look at this.
I can recreate the issue on my local machine. Note that the same error is thrown even if PSFzf isn't used, but it's likely consumed so you don't see it from the command line. I'll try and make PSFzf more robust in cases like this.
This change is available in https://www.powershellgallery.com/packages/PSFzf/2.5.4-alpha
The pre-release versions of kubectl v1.23.0 include PowerShell completion, which is provided under the hood by spf13/cobra. This works beautifully most of the time in conjunction with
Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }
:However, there seems to be an issue when there are no completions available:
(Note that pressing Ctrl + C has no effect. I have to press Enter to run the command before I can do anything else.)
I’ll reproduce it in text for legibility, though of course without the formatting:
Now, if I run the command that the application’s completion script runs under the hood, this is what I see:
Which is the result of this code:
As far as I can tell, the completion script is doing the right thing. Without PsFzf, pressing Tab does nothing if there are no completions, as you’d expect, and lets you continue your input. With PsFzf, pressing Tab with no completions available causes an error and prevents you from using Ctrl + C to cancel the input.
I’m running PsFzf v2.3.1-alpha (which I upgraded to from v2.2.9 in case it fixed this bug) with PowerShell v7.2.0 under Windows 10.0.19043 (64-bit).