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

feat: add input autocompletion #39

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Conversation

roele
Copy link
Collaborator

@roele roele commented Feb 15, 2024

Adding a 'suggestions' property to allow for autocompletion of the input. We might open a separate issue for more specialized 'file-picker' implementation.

@roele roele requested a review from jdx February 15, 2024 20:12
@roele roele linked an issue Feb 15, 2024 that may be closed by this pull request
@roele roele added the enhancement New feature or request label Feb 15, 2024
@roele roele self-assigned this Feb 15, 2024
@@ -153,6 +162,7 @@ impl<'a> Input<'a> {
return self.handle_submit();
}
}
Key::Tab => self.handle_tab()?,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of huh, the key Ctrl+E (End) is used since Tab is used to switch between the fields within a form. I find this a bit counter intuitive but if we choose to implement forms/groups (which seems non-trivial with that nasty cursor handling) we might also need to go that route.

prompt: "> ".to_string(),
placeholder: String::new(),
suggestions: vec![],
Copy link
Collaborator Author

@roele roele Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Vector is a relatively naive approach, i wonder if this is worth adding a (e.g. Trie) dependency. Question is if we need support for an insanely large set of suggestions here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played around with a Trie implementation which is 100x faster but makes case insensistive matching impossible. Also with for example 5k name suggestions, names overlap that much that the suggestion would only suggest the next character.

@roele roele force-pushed the issues/input-autocomplete branch 8 times, most recently from fb4b820 to b8cb1ff Compare February 17, 2024 02:28
@roele roele force-pushed the issues/input-autocomplete branch from b8cb1ff to dc40caf Compare February 17, 2024 14:08
@roele roele merged commit 9798d23 into jdx:main Feb 22, 2024
1 check passed
@roele roele deleted the issues/input-autocomplete branch February 22, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autocomplete
1 participant