prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Completer triggered by the Backspace key
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Currently, in CommandLineInterface used by the prompt a completer is only called when text is inserted. I want to update auto-completions also when the Backspace key is pressed. I'm working on an "AJAX" search and without support for the Backspace key, it feels awkward. Could you please add an option to trigger a completer on any buffer change, not just inserts?
The only way I can fix it for now is with a monkey patch like this:
from prompt_toolkit.interface import CommandLineInterface
_add_buffer = CommandLineInterface.add_buffer
def add_buffer(self, name, buffer, focus = False):
_add_buffer(self, name, buffer, focus)
buffer.on_text_changed += lambda _: self._async_completers[name]()
CommandLineInterface.add_buffer = add_buffer
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 in CommandLineInterface.add_buffer and inspect how _async_completers are registered and triggered. Compare the existing insert-trigger behavior with buffer.on_text_changed, then define the requested option so completers can run on any buffer change, including Backspace; verify the behavior with the relevant existing checks if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100