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

Pass selected autocomplete option through the completer #193

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpoliaw
Copy link
Contributor

@tpoliaw tpoliaw commented Dec 6, 2023

When using 'enter' to select an autocomplete suggestion, use the
autocompleter get_completion method to get the completed text before
accepting it instead of accepting just the suggestion. This allows the
completer to offer partial suggestions instead of having to offer the
full input each time.

When using 'enter' to select an autocomplete suggestion, use the
autocompleter get_completion method to get the completed text before
accepting it instead of accepting just the suggestion. This allows the
completer to offer partial suggestions instead of having to offer the
full input each time.
@tpoliaw
Copy link
Contributor Author

tpoliaw commented Dec 6, 2023

This is very much a WIP but it was easier to open a PR than to try and describe the change I was suggesting.

With the existing behaviour, when an autocomplete suggestion is selected, it feels unintuitive for 'tab' -> 'enter' to behave differently from hitting 'enter' directly. For the example case the behaviour is the same but an alternative file path completer could offer suggestions based on the current directory so for instance with the current input as /usr/ the suggestions would be bin, config, lib etc rather than /usr/bin, /usr/config, /usr/lib. When selecting one of these via tab the completer can append it to the path as required, but when hitting enter the prompt returns the suggestion (eg lib) and loses the rest of the prompt.

Would it make sense to have an accept_completion method on the trait that defaults to current behaviour to keep backwards compatibility?

I'm happy to rework this if there's a better way of doing it, (or close it if you think this is 'works as expected')

@mikaelmello
Copy link
Owner

I quite like the improvement, I'm just wondering if there are any scenarios in which the previous behaviour is the one wanted by existing users, but nothing really comes to mind

@tpoliaw
Copy link
Contributor Author

tpoliaw commented Jan 10, 2024

In case any do come up, I think it would make sense to make sure the current behaviour is still possible. I'll add the accept_completion method so that the option is there and existing users won't be affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants