-
Notifications
You must be signed in to change notification settings - Fork 102
Add autocompletion for text prompts #259
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
Conversation
|
@WilliamVenner please remove the merge. Instead, rebase your feature branch onto the current master and force push it (after reafirming it still works) |
641f506 to
c4bbef7
Compare
|
Hey, do you need me to fix that code coverage thing? It seems a bit overzealous |
|
@WilliamVenner first of, autocompletion is a great feature and thanks for that. I understand that is seems a overkill to have all this coverage, but also we are trying to maintain a well tested software so it is good for everyone. If you could add some unit tests for it would be great. If not, we see how we can deal with it and not loose also your effort. |
|
Hmmm I'm having trouble of thinking how to come up with a test for this code, which I think is the culprit of the code coverage check fail. python-inquirer/src/inquirer/render/console/_text.py Lines 26 to 39 in c4bbef7
I would be inclined to say that the test added by this PR and the already present tests should cover this code, but that's understandably not being picked up by the code coverage tool - any thoughts? |
|
@WilliamVenner we have tests to render text here: https://github.com/magmax/python-inquirer/blob/main/tests/integration/console_render/test_text.py You could add a case for autocomplete when you have tab key pressed. |
|
Thanks for your help @staticdev :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. @Cube707 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am missing some documentation. Code looks fine as is, but I tried fiddeling arround in the example and couldn't easiely get some basict to work:
- What is expected to be passed to
autocomplete? - what do functons need to return when passed to autocomplete?
I tried the obvios thing and passed a list of strings, which just failed silently..
- an example of using multiple suggestions would be helpful. Maybe something similar to this:
from itertools import cycle
suggestions = cycle(["inquirer", "hello"])
def autocomplete_fn(_text, _state):
return next(suggestions)
Cube707
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Thanks a lot @WilliamVenner ! |
|
hey guys, when do you plan on releasing this one? :p |
(Branches off of #256)
This adds the ability to add an autocompletion function to
Textprompts. The autocompletion function has similar semantics asreadline.set_completer. Pressing TAB will call the autocompletion function and set the current text to whatever it returns.