-
Notifications
You must be signed in to change notification settings - Fork 63
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
add tab-autocompletion, clear line with ctrl+c, fix minor bug #65
base: main
Are you sure you want to change the base?
Conversation
i hope there isn't an important reason to do it the other way that i'm not aware of
Hi, thanks for the PR! All looks good apart from the mechanism, could we not have some sort of trie lib like: https://docs.rs/trie-rs/latest/trie_rs/ power it? For example we could just populate it with command names automatically and do a prefix search like: 'he' -> 'he*' -> 'help','hello' Then pick the closest common prefix ('hel' here) auto complete to it, and display the rest of the results |
custom clone impl, as Trie cannot be cloned
trie_rs looks perfect for this! I just uploaded commits adding it in to replace what I wrote before. Currently, when you press Tab, it uses trie_rs's prefix search to find matching commands/arguments and provide a completion. It stores all the matching completions in state.completions, so If you keep pressing tab, it will cycle through other possible completions (e.g. typing 'hel' and pressing tab repeatedly would cycle through 'help' and 'hello'). I think displaying all matching completions would be quite useful, but I'm a bit too unfamiliar with egui to want to implement a new ui node atm. |
e.g. typing
he
and pressing tab results inhelp
. If there's another command calledheat
, pressing tab again could result inheat
.e.g. after setting up the config, you could type
set_color tur
and pressing tab results inset_color turquoise
The autocompletion code is functional but a bit verbose and messy. It annoyingly doesn't move the text cursor to the end of the line after autocompleting, I wasn't sure how to fix that, but it didn't bother me enough to try to figure it out.
I don't use github often so I'm unfamiliar with pull request etiquette, sorry if I put too many changes into a single pull request. I can try to make multiple pull requests for the individual changes if needed.