summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/comp.h1
-rw-r--r--Src/Zle/compcore.c6
-rw-r--r--Src/Zle/complist.c33
3 files changed, 32 insertions, 8 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 506d85135..57091c744 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -388,6 +388,7 @@ typedef struct chdata *Chdata;
 struct chdata {
     Cmgroup matches;		/* the matches generated */
     int num;			/* the number of matches */
+    int nmesg;			/* the number of messages */
     Cmatch cur;			/* current match or NULL */
 };
 
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 895267535..1a1241853 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -350,8 +350,9 @@ do_completion(Hookdef dummy, Compldat dat)
     if (comppatmatch && *comppatmatch && comppatmatch != opm)
 	haspattern = 1;
     if (iforcemenu) {
-	do_ambig_menu();
-	ret = 0;
+	if (nmatches)
+	    do_ambig_menu();
+	ret = !nmatches;
     } else if (useline < 0)
 	ret = selfinsert(zlenoargs);
     else if (!useline && uselist) {
@@ -511,6 +512,7 @@ after_complete(Hookdef dummy, int *dat)
 
 	cdat.matches = amatches;
 	cdat.num = nmatches;
+	cdat.nmesg = nmessages;
 	cdat.cur = NULL;
 	if ((ret = runhookdef(MENUSTARTHOOK, (void *) &cdat))) {
 	    dat[1] = 0;
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 30bc17f88..7c2fdfe57 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1632,6 +1632,7 @@ domenuselect(Hookdef dummy, Chdata dat)
     Menustack u = NULL;
     int i = 0, acc = 0, wishcol = 0, setwish = 0, oe = onlyexpl, wasnext = 0;
     int space, lbeg = 0, step = 1, wrap, pl = nlnct, broken = 0, first = 1;
+    int nolist = 0;
     char *s;
 
     if (fdat || (dummy && (!(s = getsparam("MENUSELECT")) ||
@@ -1639,6 +1640,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	if (fdat) {
 	    fdat->matches = dat->matches;
 	    fdat->num = dat->num;
+	    fdat->nmesg = dat->nmesg;
 	}
 	return 0;
     }
@@ -1753,9 +1755,14 @@ domenuselect(Hookdef dummy, Chdata dat)
 	}
 	setwish = wasnext = 0;
 
+    getk:
+
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    zbeep();
 	    break;
+	} else if (nolist && cmd != Th(z_undo)) {
+	    ungetkeycmd();
+	    break;
 	} else if (cmd == Th(z_acceptline)) {
 	    acc = 1;
 	    break;
@@ -1794,10 +1801,24 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    iforcemenu = 0;
 
 	    if (dat->num < 1 || !minfo.cur || !*(minfo.cur)) {
-		noselect = clearlist = listshown = 1;
-		onlyexpl = 0;
-		zrefresh();
-		break;
+		nolist = 1;
+		if (dat->nmesg || nmessages) {
+		    showinglist = -2;
+		    zrefresh();
+		} else {
+		    trashzle();
+		    zsetterm();
+		    if (tccan(TCCLEAREOD))
+			tcout(TCCLEAREOD);
+		    fputs("no matches\r", shout);
+		    fflush(shout);
+		    tcmultout(TCUP, TCMULTUP, nlnct);
+		    showinglist = clearlist = 0;
+		    clearflag = 1;
+		    zrefresh();
+		    showinglist = clearlist = 0;
+		}
+		goto getk;
 	    }
 	    clearlist = listshown = 1;
 	    mselect = (*(minfo.cur))->gnum;
@@ -1861,7 +1882,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		break;
 
 	    handleundo();
-	    cs = 0;
+	    cs = nolist = 0;
 	    foredel(ll);
 	    spaceinline(l = strlen(u->line));
 	    strncpy((char *) line, u->line, l);
@@ -1879,7 +1900,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		lastmatches = u->lastmatches;
 		lastlmatches = u->lastlmatches;
 		nmatches = u->nmatches;
-		hasoldlist = 1;
+		hasoldlist = validlist = 1;
 	    }
 	    freebrinfo(brbeg);
 	    freebrinfo(brend);