WillAbides / kongplete

MIT License
30 stars 9 forks source link

Repeated positional arguments #4

Closed WillAbides closed 4 years ago

WillAbides commented 4 years ago

kongplete isn't smart about positional arguments. If you have a config that takes one argument, it will continue to run that completion multiple times.

For instance, if you have a command that diffs exactly two files like diff <file 1> <file 2>, completion for the command diff a.txt b.txt would run the completion a third time even though diff doesn't take a third argument.

This is because https://github.com/posener/complete/ doesn't have a concept of positional arguments. It only provides an Args field where you can add one predictor for all arguments in the command.

One idea for addressing this is to generate predictors that respond differently based on how many tokens are between the current cursor and the subcommand it's generating completions for.