Skip to content

Autosuggestion, add optimistic (no)update ? #252

Open
@Carreau

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?

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