about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-15 14:35:16 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-15 14:35:16 +0000
commitbc9e764f4e9b95ec4c2a855c4118f6afb994e904 (patch)
treecba20ce3f39ef0f1916ddd3be6a7aa9250e3dc8f /Src
parentdefa4a7fa08ba3b9020a971d189c5ded4e151d5f (diff)
downloadzsh-bc9e764f4e9b95ec4c2a855c4118f6afb994e904.tar.gz
zsh-bc9e764f4e9b95ec4c2a855c4118f6afb994e904.tar.xz
zsh-bc9e764f4e9b95ec4c2a855c4118f6afb994e904.zip
zsh-workers/7844
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/complist.c8
-rw-r--r--Src/Zle/zle_tricky.c35
2 files changed, 34 insertions, 9 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 913a5e592..af034efab 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -375,7 +375,7 @@ complistmatches(Hookdef dummy, Chdata dat)
 		    if (m->flags & CMF_DISPLINE) {
 			nlines += 1 + printfmt(m->disp, 0, 0, 0);
 			g->flags |= CGF_HASDL;
-		    } else if ((l = strlen(m->disp)) > longest)
+		    } else if ((l = niceztrlen(m->disp)) > longest)
 			longest = l;
 		    nlist++;
 		} else if (!(m->flags & CMF_NOLIST)) {
@@ -395,7 +395,7 @@ complistmatches(Hookdef dummy, Chdata dat)
 	}
     }
     longest += 2 + of;
-    if ((ncols = (columns + 1) / longest)) {
+    if ((ncols = columns / longest)) {
 	for (g = amatches; g; g = g->next)
 	    nlines += (g->lcount - g->llcount + ncols - 1) / ncols;
     } else {
@@ -417,7 +417,7 @@ complistmatches(Hookdef dummy, Chdata dat)
 			if (m->flags & CMF_DISPLINE)
 			    nlines += 1 + printfmt(m->disp, 0, 0, 0);
 			else
-			    nlines += 1 + ((1 + niceztrlen(m->disp)) / columns);
+			    nlines += 1 + (niceztrlen(m->disp) / columns);
 		    } else if (!(m->flags & CMF_NOLIST))
 			nlines += 1 + ((1 + niceztrlen(m->str)) / columns);
 	}
@@ -678,7 +678,7 @@ complistmatches(Hookdef dummy, Chdata dat)
 			    putc(' ', shout);
 		    }
 		    a = longest - niceztrlen(m->disp ? m->disp : m->str) - 2 - of;
-		    while (a--)
+		    while (a-- > 0)
 			putc(' ', shout);
 		    if (col.cols[COL_EC])
 			tputs(col.cols[COL_EC], 1, putshout);
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index ecbfc123e..51d331f4a 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -3925,7 +3925,8 @@ addmatches(Cadata dat, char **argv)
 		aign = get_user_var(dat->ign);
 	    /* Get the display strings. */
 	    if (dat->disp)
-		disp = get_user_var(dat->disp) - 1;
+		if ((disp = get_user_var(dat->disp)))
+		    disp--;
 	    /* Get the contents of the completion variables if we have
 	     * to perform matching. */
 	    if (dat->aflags & CAF_MATCH) {
@@ -8194,6 +8195,16 @@ printfmt(char *fmt, int n, int dopr, int doesc)
 	} else {
 	    cc++;
 	    if (*p == '\n') {
+		if (dopr) {
+		    if (tccan(TCCLEAREOL))
+			tcout(TCCLEAREOL);
+		    else {
+			int s = columns - 1 - (cc % columns);
+
+			while (s-- > 0)
+			    putc(' ', shout);
+		    }
+		}
 		l += 1 + (cc / columns);
 		cc = 0;
 	    }
@@ -8201,7 +8212,16 @@ printfmt(char *fmt, int n, int dopr, int doesc)
 		putc(*p, shout);
 	}
     }
+    if (dopr) {
+	if (tccan(TCCLEAREOL))
+	    tcout(TCCLEAREOL);
+	else {
+	    int s = columns - 1 - (cc % columns);
 
+	    while (s-- > 0)
+		putc(' ', shout);
+	}
+    }
     return l + (cc / columns);
 }
 
@@ -8291,7 +8311,7 @@ ilistmatches(Hookdef dummy, Chdata dat)
 		    if (m->flags & CMF_DISPLINE) {
 			nlines += 1 + printfmt(m->disp, 0, 0, 0);
 			g->flags |= CGF_HASDL;
-		    } else if ((l = strlen(m->disp)) > longest)
+		    } else if ((l = niceztrlen(m->disp)) > longest)
 			longest = l;
 		    nlist++;
 		} else if (!(m->flags & CMF_NOLIST)) {
@@ -8310,7 +8330,7 @@ ilistmatches(Hookdef dummy, Chdata dat)
 	}
     }
     longest += 2 + of;
-    if ((ncols = (columns + 1) / longest)) {
+    if ((ncols = columns / longest)) {
 	for (g = amatches; g; g = g->next)
 	    nlines += (g->lcount + ncols - 1) / ncols;
     } else {
@@ -8328,7 +8348,12 @@ ilistmatches(Hookdef dummy, Chdata dat)
 		}
 	    } else
 		for (p = g->matches; (m = *p); p++)
-		    if (!(m->flags & CMF_NOLIST))
+		    if (m->disp) {
+			if (m->flags & CMF_DISPLINE)
+			    nlines += 1 + printfmt(m->disp, 0, 0, 0);
+			else
+			    nlines += 1 + (niceztrlen(m->disp) / columns);
+		    } else if (!(m->flags & CMF_NOLIST))
 			nlines += 1 + ((1 + niceztrlen(m->str)) / columns);
 	}
     }
@@ -8476,7 +8501,7 @@ ilistmatches(Hookdef dummy, Chdata dat)
 
 			a--;
 		    }
-		    if (i && !opl)
+		    if (i && !opl && a > 0)
 			while (a--)
 			    putc(' ', shout);
 		    if (--n)