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

completion fix

A couple of tests in do_single() looks for menucur (the current menu
completion entry) being set instead of menucmp (the flag for menu
completion), which seems to be necessary since the new completion may
be a menu completion even though no previous menu completion needs to
be removed.  The problem is menucur is not automatically reset, so
that causes the types of problem listed below.  The patch fixes it by
setting menucur to zero when the list is invalidated; I can't see how
this can be wrong, since if the list is invalid menucur is pointing at
garbage (it points into amatches which has just been freed).

% zsh -f
% mkdir foi foi/bar foo
% setopt menucomplete
  # I see some kind soul has decided it's unnecessary to have a
  # pre-defined completion for setopt, probably saving less space than
  # it takes the average user to define it in .zshrc, so I have to
  # type it out by hand.  Thanks.  (That's not the bug.)
% echo fo<TAB>
foi foo
% echo foi/
  #        ^ cursor here.  To see what's in foi with ^D, we need to stop
  # menucompletion, so I type `!<DEL>'; line remains the same.
  # (Actually, I have some binding to do it for me, but it doesn't matter.)
% echo foi/^D
  # So far so good.  Now I want to complete in foi/, so I type <TAB>
% echo fobar/

Ooops.  The completion code thinks it still has a menu entry to delete
when it inserts the new `bar'.

*** Src/Zle/zle_tricky.c.il	Wed Feb  5 09:31:35 1997
--- Src/Zle/zle_tricky.c	Fri Feb  7 11:22:40 1997
*** 2973,2978 ****
--- 2973,2979 ----
      lastambig = menucmp = showinglist = validlist = 0;
+     menucur = NULL;
  /* Get the words from a variable or a compctl -k list. */

Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.

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