1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-21 12:11:26 +01:00

users/12699: don't complete normal arguments where we're completing the

required argument to an option in the word following the option
This commit is contained in:
Peter Stephenson 2008-03-07 23:06:42 +00:00
parent 318119bda7
commit db717e3025
2 changed files with 47 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2008-03-07 Peter Stephenson <p.w.stephenson@ntlworld.com>
* users/12699: Src/Zle/computil.c: don't complete normal
arguments where we're completing the required argument
to an option in the word following the option.
2008-03-07 Peter Stephenson <pws@csr.com>
* Richard Hartmann: 24631: Completion/Unix/Command/_gpg: update.

View file

@ -1612,7 +1612,16 @@ get_cadef(char *nam, char **args)
return new;
}
/* Get the option used in a word from the line, if any. */
/*
* Get the option used in a word from the line, if any.
*
* "d" is a complete set of argument/option definitions to scan.
* "line" is the word we are scanning.
* "full" indicates that the option must match a full word; otherwise
* we look for "=" arguments or prefixes.
* *"end" is set to point to the end of the option, in some cases
* leaving an option argument after it.
*/
static Caopt
ca_get_opt(Cadef d, char *line, int full, char **end)
@ -1785,6 +1794,12 @@ ca_inactive(Cadef d, char **xor, int cur, int opts, char *optname)
typedef struct castate *Castate;
/*
* **** DOCUMENT ME ****
*
* This structure and its use are a nightmare.
*/
struct castate {
Castate snext;
Cadef d;
@ -2244,9 +2259,18 @@ ca_colonlist(LinkList l)
return ztrdup("");
}
/*
* This function adds the current set of descriptions, actions,
* and subcontext descriptions to the given linked list for passing
* up in comparguments -D and comparguments -L. opt is the
* option string (may be NULL if this isn't an option argument) and arg the
* argument structure (either an option argument or a normal argument
* as determined by arg->type).
*/
static void
ca_set_data(LinkList descr, LinkList act, LinkList subc,
char *opt, Caarg arg, int single)
char *opt, Caarg arg, Caopt optdef, int single)
{
LinkNode dnode, anode;
char nbuf[40], *buf;
@ -2297,6 +2321,19 @@ ca_set_data(LinkList descr, LinkList act, LinkList subc,
addlinknode(subc, buf);
}
/*
* If this is an argument to an option, and the option definition says
* the argument to the option is required and in the following
* (i.e. this) word, then it must match what we've just told it to
* match---don't try to match normal arguments.
*
* This test may be too stringent for what we need, or it
* may be too loose; I've simply tweaked it until it gets
* the case above right.
*/
if (arg->type == CAA_NORMAL &&
opt && optdef && optdef->type == CAO_NEXT)
return;
if (single)
break;
@ -2467,7 +2504,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
ignore_prefix(lstate->doff);
}
ca_set_data(descr, act, subc, arg->opt, arg,
(lstate->doff > 0));
lstate->curopt, (lstate->doff > 0));
}
lstate = lstate->snext;
}
@ -2565,7 +2602,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
if (opt && opt->args) {
ret = 0;
ca_set_data(descr, act, subc, opt->name, opt->args, 1);
ca_set_data(descr, act, subc, opt->name, opt->args, opt, 1);
}
lstate = lstate->snext;
}