ishell icon indicating copy to clipboard operation
ishell copied to clipboard

When AddCmd.Completer() returns an array with many strings, auto-completion prints a lot of text

Open ghost opened this issue 6 years ago • 2 comments

Hi.

First, I would like to say that the ishell module is great and very easy to use :)

Mu problem description: I wrote a simple CLI and I added an auto-completion to one of my commands. The command.Completer() method returns an array with many entries (~50K), but there is a very low number of prefixes common to them.

When I press the "tab", after I'm writing the command token, the auto-complete prints all those options, and this takes a lot of time...

Is there is a better way to handle this? It would have been nice if only the prefixes would have printed and not all of the options.

Thank you Dotan

ghost avatar Oct 17 '18 13:10 ghost

I have to admit I didn't have complex use case at the time and simply came up with something that worked for my use case.

The alternative would be to implement readline.AutoCompleter directly.

Is your code public? Or can you share a snippet that led to that scenario. That will help me in working towards something better.

abiosoft avatar Oct 17 '18 21:10 abiosoft

Hi.

Thanks for the rapid response.

I added a python script that generates a go source which demonstrates the problem and a generated file, I hope that this will help you.

generate_code.zip

ghost avatar Oct 18 '18 07:10 ghost