prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Provide custom implementation of apply_completion
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Is there an idiomatic way of overriding the behaviour of apply_completion in Buffer?
I see that the default semantics, which is suitable for most applications, is:
self.delete_before_cursor(-completion.start_position)
self.insert_text(completion.text)
However, I have a kind of niche use-case which would be catered for better if there was an idiomatic way to reliably change this behaviour. For example, the most general interface I can imagine is effectively a function that rewrites the line and cursor position arbitrarily.
I apologise if there's a simple Python trick that I'm unaware of that would permit me to override this (I've tried various modifications to the example autocomplete-with-control-space.py to no avail) or if permitting this could have unintended interactions with other parts of the completer infrastructure that I haven't considered.
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 by reading Buffer.apply_completion and the autocomplete-with-control-space.py example to understand how completion application is currently reached. Define what an idiomatic customization point should guarantee for arbitrary line and cursor rewrites, including its interaction with the completer infrastructure; the issue is done when that behavior is supported and documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100