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

Re: completion just after an option by _arguments.



Tanaka Akira wrote:

> I found a problem with _arguments.
> 
> Z:akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% _tst () { _arguments '-x[desc]' }
> is27e1u11% zstyle ':completion*:messages' format '%d'
> is27e1u11% tst -x<TAB>
> no arguments
> 
> It should insert a space.  3.1.6-pws-6 works so.

Whew. This tries to fix it (it had inactivated the option description
after it had found it, the patch basically makes it be activated again 
in such cases).

Note that with `_arguments -s ...' the behaviour is still the same,
but I think thats ok. At least I currently don't see a solution for
that. Hm. maybe some trickery in _arguments...

Bye
 Sven

diff -ru ../z.old/Src/Zle/computil.c Src/Zle/computil.c
--- ../z.old/Src/Zle/computil.c	Mon Jan 31 11:35:54 2000
+++ Src/Zle/computil.c	Mon Jan 31 12:35:05 2000
@@ -1019,7 +1019,7 @@
 ca_parse_line(Cadef d)
 {
     Caarg adef, ddef;
-    Caopt ptr;
+    Caopt ptr, wasopt;
     struct castate state;
     char *line, *pe;
     int cur, doff;
@@ -1107,6 +1107,8 @@
 
 	pe = NULL;
 
+	wasopt = NULL;
+
 	/* See if it's an option. */
 
 	if (state.opt == 2 && (state.curopt = ca_get_opt(d, line, 0, &pe)) &&
@@ -1141,8 +1143,11 @@
 	    }
 	    if (state.def)
 		state.opt = 0;
-	    else
+	    else {
+		if (!d->single || (state.curopt->name[1] && state.curopt->name[2]))
+		    wasopt = state.curopt;
 		state.curopt = NULL;
+	    }
 	} else if (state.opt == 2 && d->single &&
 		   (state.curopt = ca_get_sopt(d, line, 0, &pe))) {
 	    /* Or maybe it's a single-letter option? */
@@ -1262,6 +1267,8 @@
 		ca_laststate.optbeg = state.nargbeg;
 		ca_laststate.argbeg = state.restbeg;
 		ca_laststate.singles = state.singles;
+		if (wasopt)
+		    wasopt->active = 1;
 	    }
 	}
     }

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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