mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
49499 based on 49496 by Jun T.: fixes to option -A of _arguments
This commit is contained in:
parent
f414456b7a
commit
e40938c128
3 changed files with 57 additions and 8 deletions
|
@ -1,5 +1,8 @@
|
|||
2021-10-23 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 49499 based on 49496 by Jun T.: Src/Zle/computil.c
|
||||
Test/Y03arguments.ztst: fixes to option -A of _arguments
|
||||
|
||||
* 49500: Completion/Linux/Command/_lsns: new completion
|
||||
|
||||
2021-10-16 dana <dana@dana.is>
|
||||
|
|
|
@ -2031,9 +2031,9 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
|
|||
state.def = state.ddef = NULL;
|
||||
state.curopt = state.dopt = NULL;
|
||||
state.argbeg = state.optbeg = state.nargbeg = state.restbeg = state.actopts =
|
||||
state.nth = state.inopt = state.inarg = state.opt = state.arg = 1;
|
||||
state.nth = state.inarg = state.opt = state.arg = 1;
|
||||
state.argend = argend = arrlen(compwords) - 1;
|
||||
state.singles = state.oopt = 0;
|
||||
state.inopt = state.singles = state.oopt = 0;
|
||||
state.curpos = compcurrent;
|
||||
state.args = znewlinklist();
|
||||
state.oargs = (LinkList *) zalloc(d->nopts * sizeof(LinkList));
|
||||
|
@ -2080,9 +2080,14 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
|
|||
remnulargs(line);
|
||||
untokenize(line);
|
||||
|
||||
ca_inactive(d, argxor, cur - 1, 0);
|
||||
if ((d->flags & CDF_SEP) && cur != compcurrent && !strcmp(line, "--")) {
|
||||
if (argxor) {
|
||||
ca_inactive(d, argxor, cur - 1, 0);
|
||||
argxor = NULL;
|
||||
}
|
||||
if ((d->flags & CDF_SEP) && cur != compcurrent && state.actopts &&
|
||||
!strcmp(line, "--")) {
|
||||
ca_inactive(d, NULL, cur, 1);
|
||||
state.actopts = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2235,11 +2240,17 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
|
|||
} else if (multi && (*line == '-' || *line == '+') && cur != compcurrent
|
||||
&& (ca_foreign_opt(d, all, line)))
|
||||
return 1;
|
||||
else if (state.arg &&
|
||||
(!napat || cur <= compcurrent || !pattry(napat, line))) {
|
||||
else if (state.arg && cur <= compcurrent) {
|
||||
/* Otherwise it's a normal argument. */
|
||||
if (napat && cur <= compcurrent)
|
||||
|
||||
/* test pattern passed to -A. if it matches treat this as an unknown
|
||||
* option and continue to the next word */
|
||||
if (napat && cur < compcurrent && state.actopts) {
|
||||
if (pattry(napat, line))
|
||||
continue;
|
||||
ca_inactive(d, NULL, cur + 1, 1);
|
||||
state.actopts = 0;
|
||||
}
|
||||
|
||||
arglast = 1;
|
||||
/* if this is the first normal arg after an option, may have been
|
||||
|
@ -2293,7 +2304,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
|
|||
if (adef)
|
||||
state.oopt = adef->num - state.nth;
|
||||
|
||||
if (state.def)
|
||||
if (state.def && cur != compcurrent)
|
||||
argxor = state.def->xor;
|
||||
|
||||
if (state.def && state.def->type != CAA_NORMAL &&
|
||||
|
|
|
@ -359,6 +359,12 @@
|
|||
0:allowed option before --
|
||||
>line: {tst -x }{ --}
|
||||
|
||||
tst_arguments -S '1:one' '2:two'
|
||||
comptest $'tst -- -- \t'
|
||||
0:only first of duplicate -- is ignored
|
||||
>line: {tst -- -- }{}
|
||||
>DESCRIPTION:{two}
|
||||
|
||||
tst_arguments -x :word
|
||||
comptest $'tst word -\t'
|
||||
0:option after a word
|
||||
|
@ -390,6 +396,25 @@
|
|||
0:continue completion after rest argument that looks like an option
|
||||
>line: {tst -a -x more }{}
|
||||
|
||||
tst_arguments -A '-*' -a -b '*: :(words)'
|
||||
comptest $'tst -x -\t'
|
||||
0:word matching -A pattern doesn't exclude options
|
||||
>line: {tst -x -}{}
|
||||
>DESCRIPTION:{option}
|
||||
>NO:{-a}
|
||||
>NO:{-b}
|
||||
|
||||
tst_arguments -A '-*' -a -b '1:word:(word)'
|
||||
comptest $'tst -x \t'
|
||||
0:unrecognised word matching -A pattern not treated as a rest argument
|
||||
>line: {tst -x word }{}
|
||||
|
||||
tst_arguments -A "-*" '(3)-a' '1:one' '2:two' '3:three' '4:four' '*:extra'
|
||||
comptest $'tst x -a \t'
|
||||
0:exclusion from option following word matching -A pattern should not apply
|
||||
>line: {tst x -a }{}
|
||||
>DESCRIPTION:{three}
|
||||
|
||||
tst_arguments '*-v'
|
||||
comptest $'tst -v -\t'
|
||||
0:repeatable options
|
||||
|
@ -478,6 +503,16 @@
|
|||
>NO:{-b}
|
||||
>NO:{-v}
|
||||
|
||||
tst_arguments -a -b -c '(-a)1:one' '(-b)2:two' '(-c)*:extra'
|
||||
comptest $'tst x y z\e6\C-b-\t'
|
||||
0:exclude option from normal argument to the right of the cursor
|
||||
>line: {tst -}{ x y z}
|
||||
>DESCRIPTION:{one}
|
||||
>DESCRIPTION:{option}
|
||||
>NO:{-a}
|
||||
>NO:{-b}
|
||||
>NO:{-c}
|
||||
|
||||
tst_arguments -a - set1 -d - set2 '(set2)-m' -n -o ':arg:(x)' - set2 -x
|
||||
comptest $'tst -m \t'
|
||||
0:exclude own set from an option
|
||||
|
|
Loading…
Reference in a new issue