Commit bd961b3
committed
Fix zsh nested subcommand option completion
In zsh completion context, the words array excludes the command name, so
subcommands are not matched and per-subcommand options are not
suggested.
To fix that, use `$words[1]` instead of `$words[2]` when dispatching
nested subcommands in generated zsh completions.
For reference, see zshcompsys's manpage [1]:
$ man zshcompsys | col -bx | grep -F -A 13 '*::message:action'
*::message:action
*:::message:action
This describes how arguments (usually non-option
arguments, those not beginning with - or +) are to be
completed when neither of the first two forms was
provided. Any number of arguments can be completed in
this fashion.
With two colons before the message, the words special
array and the CURRENT special parameter are modified to
refer only to the normal arguments when the action is
executed or evaluated. With three colons before the
message they are modified to refer only to the normal
arguments covered by this description.
Also confirmed that this issue is zsh-specific. Bash and fish
completions work fine.
[1]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html1 parent e69d51d commit bd961b3
3 files changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | | - | |
| 682 | + | |
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
984 | | - | |
| 984 | + | |
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
| |||
1155 | 1155 | | |
1156 | 1156 | | |
1157 | 1157 | | |
1158 | | - | |
| 1158 | + | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | 1161 | | |
| |||
2056 | 2056 | | |
2057 | 2057 | | |
2058 | 2058 | | |
2059 | | - | |
| 2059 | + | |
2060 | 2060 | | |
2061 | 2061 | | |
2062 | 2062 | | |
| |||
0 commit comments