Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autosuggestion, add optimistic (no)update ? #252

Open
Carreau opened this issue Feb 26, 2016 · 2 comments
Open

Autosuggestion, add optimistic (no)update ? #252

Carreau opened this issue Feb 26, 2016 · 2 comments

Comments

@Carreau
Copy link
Contributor

Carreau commented Feb 26, 2016

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?

@jonathanslenders
Copy link
Member

I think this makes sense. I'll have a look later this week.

@Carreau
Copy link
Contributor Author

Carreau commented Feb 29, 2016

No hurry, it seem also pretty easy for a newcomer to investigate the codebase. :-P

Carreau added a commit to Carreau/python-prompt-toolkit that referenced this issue Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants