prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Always display first completion
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
With prompt_toolkit 1 it was possible to return multiple completions and always first completion was selected. After update to PT2, this isn't possible. When I try to complete with TAB key, only partial completion is used (only "msg" string) and second TAB should be pressed to full completion. Can I somehow emulate PT1 behaviour? Here is my example code:
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
class MyCustomCompleter(Completer):
def get_completions(self, document, complete_event):
yield Completion('msg test', start_position=0)
yield Completion('msg help', start_position=0)
text1 = prompt(">> ",
completer=MyCustomCompleter(),
complete_while_typing=True,
reserve_space_for_menu=0
)
print("RESULT:", repr(text1))
I need after first TAB to see "msg test" in prompt.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MyCustomCompleter.get_completions example and the prompt call using prompt_toolkit 2. Run it and inspect how the first TAB handles the two yielded Completion objects. Done means the first TAB inserts the full "msg test" completion, matching the reported prompt_toolkit 1 behavior.
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
- Clearly specified
- Newbie friendliness
- 45/100