Skip to content

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

Open

Description

@shellwhale

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

Activity

  1. Daydreamer-riri commented on Aug 5, 2024

    @Daydreamer-riri

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

    image
    image

    image
    image

  2. daxian-dbw commented on Aug 5, 2024

    @daxian-dbw
    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.

  3. Daydreamer-riri commented on Aug 15, 2024

    @Daydreamer-riri

    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.

  4. nebula-it commented on Jan 27, 2026

    @nebula-it

    Any update on that work? For now is it possible to just extend the 20ms time window (or make it customizable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions