Skip to content

Autosuggestion, add optimistic (no)update ? #252

Open

Description

@Carreau

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?

Activity

  1. jonathanslenders commented on Feb 29, 2016

    @jonathanslenders
    Member

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

  2. Carreau commented on Feb 29, 2016

    @Carreau
    ContributorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions