-
Notifications
You must be signed in to change notification settings - Fork 17
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
Tab completion in zsh broken in 0.9.5? #303
Comments
Will take a look in a few hours/tomorrow. |
Problem is related to having "value" items ( As a quick fix if you remove |
I tried that, and it certainly improved. However As soon as I add another letter (e.g. EDIT: I assume bpaf adds builtin support for -- (i.e. to treat the remaining arguments as plain positional arguments), it is certainly not something I have added myself as far as I know. |
Hmm... Probably still related to positional items. Making slow progress on the next version so hopefully soon :) |
Rubberducking/note to self. Let's consider a minimal possible parser that picks between adding a The way completion works for alternative branches is by trying to run both branches and picking completion results from both (if both branches fail the same way or succeed) or one that succeeds (or tries harder (*)), so to get completion both need to produce the same result. To be able to tell the difference between user trying to complete With flag I can tell the difference between something passed by user and something inserted by the shell for completion purposes and make positional parser to fail on I can't even mark it as failing in a second layer since this counts as failing while trying harder. Possible options I see so far are:
(2) seem like the easiest way forward for now. Either way I need to add more internal documentation about assumptions made for completion - trying to remember how it works is hard. |
I don't know the internals of bpaf, but is there no additional metadata that could be useful that the shell provides? I have hand written zsh completion files in the past, and it provides a host of useful environment variables, such as cursor position etc (I don't know about the other shells, and what they provide likely differs, so maybe not very useful to you.) |
All the shells provide more or less the same info and I don't think any additional info from the shell will help, it's all about the internal representation. Anyway, after an hour of cleaning up the front yard I came up with some more ideas to try, a variation on (2), but deciding what completions to keep depending on what was consumed and how it might conflict. Now I'm back to experimenting :) |
Got something working. Can you check if branch |
As for the other shelles (fish etc) I don't have those installed, so can't help there |
Hmm... Looking... |
Reproduced the problem you are having locally by copying your whole parser configuration in my tests :) Fixing. |
Took some thinking time, pushed a new version of |
Hm, not quite yet: Here is a weird one in zsh: $ target/debug/chezmoi_modify_manager -a <tab>
$ target/debug/chezmoi_modify_manager -a --style That should have accepted filenames as well. --style (also known as -t) is not a required argument. $ target/debug/chezmoi_modify_manager --he<tab>
$ target/debug/chezmoi_modify_manager --help- Plain old --help also exist (as well as --help-syntax and --help-transforms) $ target/debug/chezmoi_modify_manager -u <tab>
# List of files and all global flags, like --doctor, neither of which is correct, the only real one is --no-confirm which is a valid optional flag.
$ target/debug/chezmoi_modify_manager -u --doctor
Error: `--doctor` cannot be used at the same time as `-u`
# That is what I expect, but tab completion didn't understand Seems tricky to get this right! |
Hmm... Instruction to zsh to accept filenames is generated though... I wonder. |
Ouch, I should also warn that my zsh setup is not exactly vanilla. So I hope I'm not leading you down a wild goose chase here. Please check that you can reproduce it first! I'm still using the (sadly no longer really maintained) zsh4humans. I should probably get around to using something else. Any year now. ;) |
It appears at some point tab completion broke for my project https://github.com/VorpalBlade/chezmoi_modify_manager using bpaf, it doesn't work with version 0.9.5 any more at least.
It can no longer complete the flags, only files.
Looking at the output manually shows this too:
which is odd since:
Here is the source code for the parser: https://github.com/VorpalBlade/chezmoi_modify_manager/blob/e7d117943b5b0522eadcb6ab00fa8aa524926572/src/arguments.rs
It has definitely worked before, but the command is primarily called indirectly by scripts or other commands, so I don't know exactly when it broke.
EDIT: I wrote zsh in the title since I don't use other shells and don't have tab completion for this command set up in them.
The text was updated successfully, but these errors were encountered: