Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: minor niggle with svn completion of sub-commands



On Nov 15,  2:47am, Greg Klanderman wrote:
} 
} Here's a simple test showing that the '*::...' type argument
} descriptions are not handled correctly by _arguments:

It all goes awry at computil.c line 2133:

	    if ((adef = state.def = ca_get_arg(d, state.nth)) &&
		(state.def->type == CAA_RREST ||
		 state.def->type == CAA_RARGS)) {

for the '*::' case, state.def->type == CAA_RREST so we enter the block
at 2136 and exit the entire loop at the "break" on 2151.  Line 2133 is
the only place that RREST and RARGS are treated differently than REST
(line 2173 doesn't count as that's for the case of an argument of an
option ("optspec"), not a "normal argument").

The problem seems to be that we blindly clobber ca_laststate upon
discovering that we've reached the "rest" description.  The patch
below changes this behavior but I'm not certain it's complete; it
may need an "else" clause, or maybe we should be breaking out of
the entire loop elsewhere as soon as ca_laststate.def is non-NULL.

This patch may claim it applies with an offset, it's a diff against
my own repository rather than the official one.

Index: computil.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/Zle/computil.c,v
retrieving revision 1.32
diff -c -r1.32 computil.c
--- computil.c	23 Nov 2008 18:26:28 -0000	1.32
+++ computil.c	16 Nov 2009 00:10:26 -0000
@@ -2130,10 +2144,12 @@
 		for (; line; line = compwords[cur++])
 		    zaddlinknode(state.args, ztrdup(line));
 
-		memcpy(&ca_laststate, &state, sizeof(state));
-		ca_laststate.ddef = NULL;
-		ca_laststate.dopt = NULL;
-		ca_laststate.doff = 0;
+		if (!ca_laststate.def) {
+		    memcpy(&ca_laststate, &state, sizeof(state));
+		    ca_laststate.ddef = NULL;
+		    ca_laststate.dopt = NULL;
+		    ca_laststate.doff = 0;
+		}
 		break;
 	    }
 	    zaddlinknode(state.args, ztrdup(line));



Messages sorted by: Reverse Date, Date, Thread, Author