prompt-toolkit / prompt-toolkit/python-prompt-toolkit

get_completions() needing an external command

Open
#1,106 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Hello all,
my completion workflow differs from the one shown in the examples: i need to execute a command taking for argument the word and returning the list of possible completions.

I don't succeed to make it work because I don't get the async functionning of the module. While debugging, I see that my script tries to execute the command with word='' instead of the letters I typed in the prompt.

class MyCompleter(Completer):
    def get_completions(self, document, complete_event):
      word = document.get_word_before_cursor()
      completion_propositions = external_command(word)
      for proposition in completion_propositions:
        yield Completion(proposition, start_position=-len(word))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the get_completions example shown in the issue, especially document.get_word_before_cursor and the external_command call. Reproduce the completion flow while typing and trace why the command receives an empty word; the work is done when the typed word is passed to the external command and its returned propositions are yielded.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.