Skip to content

Request: a way to show tab completions #3

@wch

Description

@wch

First off, thanks for creating this package.

I'm using it create a REPL using Pyodide (Python compiled to wasm), and I would like to add support for tab completions. The idea is that when you press tab, it does one of the following (which is similar to the normal python REPL):

  • If there are zero possible completions, then nothing happens.
  • If there is one possible completion, it completes it.
  • If there are two or more possible completions, then it fills in any following characters that are present in all of the possible completions, and then displays the possible completions.

I don't see a good way to do this with the existing API. One way to go would be to provide a way register a completion handler; this handler would be a function which takes a string (the text typed on the command line so far) and returns an array of strings (the list of possible completions).

So the usage would be something like this:

    readline.setCompletionHandler((text: string): string[] => {
      // Do stuff here
    })    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions