zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: Yet another completion bugfix
Date: Wed, 9 Aug 1995 06:00:14 +0100 (BST)	[thread overview]
Message-ID: <7934.199508090500@stone.dcs.warwick.ac.uk> (raw)

-----BEGIN PGP SIGNED MESSAGE-----

Yet another fix of something I broke.  Thanks to Zoltan for diagnosing
this one.  When LIST_AMBIGUOUS is unset and AUTO_LIST is set, and a
completion is ambiguous but has an unambiguous prefix, zsh falls over
on some platforms.  The problem is that the unambiguous prefix being
completed requires the completion list to be invalidated, but the
options require the list to be shown.  I think these circumstances are
the only ones that cause that problem.

The solution is in two parts: first, extra code in invalidatelist(),
that checks to see if the list is supposed to be shown but hasn't been
yet (showinglist==-2).  If that is the case, it calls listmatches()
itself before freeing up the array memory and setting the appropriate
flags.  Second, a little special-case code in do_ambiguous() to make
sure showinglist is set *before* invalidatelist() is called, in the
case where it matters.  In this patch I also add a sanity check to
listmatches(), so that if this problem recurs it will be immediately
obvious on all platforms.  (The error message won't even mess up the
screen!)

 -zefram

      *** Src/zle_tricky.c.1.19	1995/08/09 04:03:38
      --- Src/zle_tricky.c	1995/08/09 04:46:05
      ***************
      *** 3049,3054 ****
      --- 3049,3056 ----
        void
        invalidatelist(void)
        {
      +     if(showinglist == -2)
      + 	listmatches();
            if(validlist) {
        	freearray(amatches);
        	zsfree(rpre);
      ***************
      *** 3179,3184 ****
      --- 3181,3187 ----
        do_ambiguous(void)
        {
            int p = (usemenu || ispattern), atend = (cs == we);
      +     int inv = 0;
        
            menucmp = 0;
        
      ***************
      *** 3201,3208 ****
        	    if (ae && !atend)
        		inststrlen(firstm + strlen(firstm) - ae, 0, ae);
        	    if(ab || (ae && !atend))
      ! 		invalidatelist();
        	    if (isset(LISTAMBIGUOUS) && (ab || (ae && !atend))) {
        		lastambig = 0;
        		return;
        	    }
      --- 3204,3212 ----
        	    if (ae && !atend)
        		inststrlen(firstm + strlen(firstm) - ae, 0, ae);
        	    if(ab || (ae && !atend))
      ! 		inv = 1;
        	    if (isset(LISTAMBIGUOUS) && (ab || (ae && !atend))) {
      + 		invalidatelist();
        		lastambig = 0;
        		return;
        	    }
      ***************
      *** 3212,3217 ****
      --- 3216,3223 ----
        	/* And finally list the matches if needed (and requested). */
        	if (isset(AUTOLIST) && !amenu && !showinglist)
        	    showinglist = -2;
      + 	if(inv)
      + 	    invalidatelist();
            }
        }
        
      ***************
      *** 3505,3510 ****
      --- 3511,3524 ----
            int of = (isset(LISTTYPES) && !(haswhat & HAS_MISC));
            char **arr, **ap, sav;
            int nfpl, nfsl, nlpl, nlsl;
      + 
      +     /* Sanity check */
      +     if(!validlist) {
      + 	trashzle();
      + 	fputs("BUG: listmatches called with bogus list\n", shout);
      + 	showinglist = 0;
      + 	return;
      +     }
        
            /* Calculate lengths of prefixes/suffixes to be added */
            nfpl = fpre ? nicestrlen(fpre) : 0;

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBMChAz2WJ8JfKi+e9AQHLZwH7BsjFJBxnCCeKZS0cjNLGobufBS/U1AF1
rJLX83icUeBCu7cDAFBSjLcSn0t80Y6Eo6y8Qixl2zMQg2EhjHl++w==
=pwy3
-----END PGP SIGNATURE-----


                 reply	other threads:[~1995-08-09  5:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7934.199508090500@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).