zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@math.gatech.edu
Subject: PATCH: Re: 3.1.5++ completion listing problem
Date: Mon, 14 Dec 1998 10:17:09 +0100 (MET)	[thread overview]
Message-ID: <199812140917.KAA05583@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Sat, 12 Dec 1998 07:55:59 -0800


Bart Schaefer wrote:

> ...
> 
> I'd suggest simply deleting the "if (smatches < 2)" block, but perhaps
> Sven can tell us what side-effect that may have elsewhere?

The problem with simply removing the test is that the completion code
may now produce multiple matches for which only one would have to be
listed and in this case the matched string would be inserted and
AUTO_LIST would show the `list of matches' (i.e. one string).

But by moving the test up into do_ambiguous() this should be fixed.

The patch below also fixes a problem with lists for multiple groups of 
matches taht sometimes caused ALWAYS_LAST_PROMPT to move the cursor up 
to the wrong line.

Bye
 Sven

P.S.: The hunks will apply with an offset, never mind...

*** os/Zle/zle_tricky.c	Wed Dec  9 15:45:46 1998
--- Src/Zle/zle_tricky.c	Mon Dec 14 10:08:14 1998
***************
*** 4890,4896 ****
       * if it is needed.                                                     */
      if (isset(LISTBEEP))
  	feep();
!     if (isset(AUTOLIST) && !amenu && !showinglist)
  	showinglist = -2;
      if (am)
  	lastambig = 1;
--- 5061,5067 ----
       * if it is needed.                                                     */
      if (isset(LISTBEEP))
  	feep();
!     if (isset(AUTOLIST) && !amenu && !showinglist && smatches >= 2)
  	showinglist = -2;
      if (am)
  	lastambig = 1;
***************
*** 5211,5224 ****
      Cmgroup g;
      Cmatch *p, m;
      Cexpl *e;
!     int nlines = 0, ncols, colsz, ngr = 0, nlist = 0, longest = 1, pnl = 0;
      int of = isset(LISTTYPES), opl = 0;
      int listmax = getiparam("LISTMAX");
  
-     if (smatches < 2) {
- 	showinglist = 0;
- 	return;
-     }
  #ifdef DEBUG
      /* Sanity check */
      if(!validlist) {
--- 5382,5391 ----
      Cmgroup g;
      Cmatch *p, m;
      Cexpl *e;
!     int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0;
      int of = isset(LISTTYPES), opl = 0;
      int listmax = getiparam("LISTMAX");
  
  #ifdef DEBUG
      /* Sanity check */
      if(!validlist) {
***************
*** 5288,5303 ****
  		e++;
  	    }
  	}
- 	if (g->lcount)
- 	    ngr++;
      }
      longest += 2 + of;
      if ((ncols = (columns + 1) / longest)) {
! 	colsz = (nlist + ncols - 1) / ncols;
! 	nlines += ngr - 1 + colsz + (nlist == 0);
      } else {
  	ncols = 1;
- 	colsz = 1;
  	opl = 1;
  	for (g = amatches; g; g = g->next) {
  	    char **pp = g->ylist;
--- 5455,5467 ----
  		e++;
  	    }
  	}
      }
      longest += 2 + of;
      if ((ncols = (columns + 1) / longest)) {
! 	for (g = amatches; g; g = g->next)
! 	    nlines += (g->lcount + ncols - 1) / ncols;
      } else {
  	ncols = 1;
  	opl = 1;
  	for (g = amatches; g; g = g->next) {
  	    char **pp = g->ylist;
***************
*** 5374,5385 ****
  		}
  	    }
  	    else {
! 		int n = g->lcount, nl = (n + ncols - 1) / ncols, i, a;
! 		int nc = (opl ? 1 : (n + colsz - 1) / colsz);
  		char **pq;
  
  		while (n && nl--) {
! 		    i = nc;
  		    pq = pp;
  		    while (n && i--) {
  			if (pq - g->ylist >= g->lcount)
--- 5538,5548 ----
  		}
  	    }
  	    else {
! 		int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, a;
  		char **pq;
  
  		while (n && nl--) {
! 		    i = ncols;
  		    pq = pp;
  		    while (n && i--) {
  			if (pq - g->ylist >= g->lcount)
***************
*** 5390,5396 ****
  			    while (a--)
  				putc(' ', shout);
  			}
! 			pq += colsz;
  			n--;
  		    }
  		    if (n)
--- 5553,5559 ----
  			    while (a--)
  				putc(' ', shout);
  			}
! 			pq += nc;
  			n--;
  		    }
  		    if (n)
***************
*** 5400,5407 ****
  	    }
  	}
  	else if (g->lcount) {
! 	    int n = g->lcount, nl = (n + ncols - 1) / ncols, i, j, a;
! 	    int nc = (opl ? 1 : (n + colsz - 1) / colsz);
  	    Cmatch *q;
  
  	    if (n && pnl) {
--- 5563,5569 ----
  	    }
  	}
  	else if (g->lcount) {
! 	    int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, j, a;
  	    Cmatch *q;
  
  	    if (n && pnl) {
***************
*** 5409,5415 ****
  		pnl = 0;
  	    }
  	    for (p = skipnolist(g->matches); n && nl--;) {
! 		i = nc;
  		q = p;
  		while (n && i--) {
  		    if (!(m = *q))
--- 5571,5577 ----
  		pnl = 0;
  	    }
  	    for (p = skipnolist(g->matches); n && nl--;) {
! 		i = ncols;
  		q = p;
  		while (n && i--) {
  		    if (!(m = *q))
***************
*** 5438,5444 ****
  			while (a--)
  			    putc(' ', shout);
  		    if (--n)
! 			for (j = colsz; j && *q; j--)
  			    q = skipnolist(q + 1);
  		}
  		if (n) {
--- 5600,5606 ----
  			while (a--)
  			    putc(' ', shout);
  		    if (--n)
! 			for (j = nc; j && *q; j--)
  			    q = skipnolist(q + 1);
  		}
  		if (n) {


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~1998-12-14  9:44 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=199812140917.KAA05583@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --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).