prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Autosuggestion, add optimistic (no)update ?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I got a lag when the autosuggestion take times to build the list of suggestion,
assuming vertically is time, and | is my cursor:
imp|ort
impo|
impo|rt
impo|
impor|t
You can easily reproduce that with :
from prompt_toolkit import prompt
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
class MyHist(InMemoryHistory):
def __iter__(self):
import time
time.sleep(0.3)
return super().__iter__()
history = MyHist()
while True:
text = prompt('> ', history=history, auto_suggest=AutoSuggestFromHistory())
print('You said: %s' % text)
My guess is that it should be possible to optimistically keep the previous suggestion if the new type letter is the same than the first one of the (previous) suggestions or something similar, or better, if current string is subset of current suggestion, keep it.
Thoughts?
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 provided prompt_toolkit reproduction, especially the delayed MyHist.iter and AutoSuggestFromHistory setup, and trace how suggestions are refreshed while typing. Done should mean the visible suggestion does not briefly regress or disappear during delayed refresh, with the optimistic-update behavior and its tests agreed.
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
- Needs clarification
- Newbie friendliness
- 25/100