Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predictive completion not working with completion scripts generated by the cobra library #24

Open
3 tasks done
shellwhale opened this issue Apr 19, 2023 · 3 comments
Open
3 tasks done

Comments

@shellwhale
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

  1. Import the CompletionPredictor module with Import-Module -Name CompletionPredictor
  2. Set the PredictionSource option to HistoryAndPlugin with Set-PSReadLineOption -PredictionSource HistoryAndPlugin
  3. Generate and execute a cobra-generated completion script (e.g., kubectl completion powershell | Out-String | Invoke-Expression)
  4. Type a command that uses the completion script (e.g., kubectl get pods) and try to use predictive completion.

Expected behavior

~ ❯ kubectl get
> kubectl get pods                                                                         [Completion]
> kubectl get csr                                                                          [Completion]
> kubectl get nodes                                                                        [Completion]
> ...

Actual behavior

~ ❯ kubectl get
> kubectl get pods                                                                         [History]

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.1.0

Visuals

No response

@Daydreamer-riri
Copy link

‌‌‌‌‌‌Hi @daxian-dbw, currently, all custom completions and executable files do not prompt. Is there a way to achieve this functionality?

image
image

image
image

@daxian-dbw
Copy link
Member

Unfortunately, the completion for native commands doesn't work with completion predictor today because they are too slow.
For a predictor to work with PSReadLine today, it needs to return results within 20ms, which is impossibly for most of native command completers. We have a work item in PSReadLine to allow longer timeout by separating the prediction rendering from the user typing rendering, but we haven't got to it yet.

@Daydreamer-riri
Copy link

Thanks for your reply! I've just seen the latest vscode terminal integration do something similar, but I'm using Windows Terminal more often than not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants