zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: 3.1.5++ completion listing problem
@ 1998-12-14  9:17 Sven Wischnowsky
  0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 1998-12-14  9:17 UTC (permalink / raw)
  To: zsh-workers


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-12-14  9:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-14  9:17 PATCH: Re: 3.1.5++ completion listing problem Sven Wischnowsky

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).