zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-workers@sunsite.dk
Subject: Re: Menu selection
Date: Fri, 5 Jul 2002 10:09:03 +0200	[thread overview]
Message-ID: <15653.21535.954397.86417@wischnow.berkom.de> (raw)
In-Reply-To: <20020704175642.50849.qmail@web10403.mail.yahoo.com>


Felix Rosencrantz wrote:

> It's more robust, but still seeing some problems.  He is the use case.
> I was able to get my shell to crash, but not with this use case.  
> The use case does scream BUG, so hopefully that will help track the problem.

Urgh, it gets embarassing.

And I can't reproduce this either. In fact, I had seen something like
this before the last patch and fixed it. At least I thought I did.

That message should mean that somehow `showinglist' gets set to `-2'
when leavin menu selection even though there isn't a list to show. I
can only try to make the tests a bit more secure (by also testing
`nolist').

The other hunks improve the behaviour of interactive mode when the
string typed doesn't match anything (it doesn't leave menu selection
so that one can use undo and backspace to go back).


Bye
  Sven

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.53
diff -u -r1.53 complist.c
--- Src/Zle/complist.c	4 Jul 2002 09:29:22 -0000	1.53
+++ Src/Zle/complist.c	5 Jul 2002 08:06:45 -0000
@@ -1724,7 +1724,7 @@
     Brinfo brbeg;
     Brinfo brend;
     int nbrbeg, nbrend;
-    int cs, acc, nmatches, mline, mlbeg;
+    int cs, acc, nmatches, mline, mlbeg, nolist;
     struct menuinfo info;
     Cmgroup amatches, pmatches, lastmatches, lastlmatches;
     char *origline;
@@ -1768,10 +1768,13 @@
         p = (char *) zhalloc(cs - wb + 1);
         strncpy(p, (char *) line + wb, cs - wb);
         p[cs - wb] = '\0';
-        s = (char *) zhalloc(lastend - cs + 1);
-        strncpy(s, (char *) line + cs, lastend - cs);
-        s[lastend - cs] = '\0';
-
+        if (lastend < cs)
+            s = "";
+        else {
+            s = (char *) zhalloc(lastend - cs + 1);
+            strncpy(s, (char *) line + cs, lastend - cs);
+            s[lastend - cs] = '\0';
+        }
         cs = 0;
         foredel(ll);
         spaceinline(sll);
@@ -2117,7 +2120,9 @@
             molbeg = -1;
 	    break;
 	} else if (nolist && cmd != Th(z_undo) &&
-                   (!mode || cmd != Th(z_backwarddeletechar))) {
+                   (!mode || (cmd != Th(z_backwarddeletechar) &&
+                              cmd != Th(z_selfinsert) &&
+                              cmd != Th(z_selfinsertunmeta)))) {
 	    ungetkeycmd();
 	    break;
 	} else if (cmd == Th(z_acceptline)) {
@@ -2162,6 +2167,7 @@
 	    s->pmatches = pmatches;
 	    s->lastmatches = lastmatches;
 	    s->lastlmatches = lastlmatches;
+            s->nolist = nolist;
 	    s->acc = menuacc;
 	    s->brbeg = dupbrinfo(brbeg, NULL, 1);
 	    s->brend = dupbrinfo(brend, NULL, 1);
@@ -2258,6 +2264,7 @@
 	    memcpy(&(s->info), &minfo, sizeof(struct menuinfo));
 	    s->amatches = s->pmatches =
 		s->lastmatches = s->lastlmatches = NULL;
+            s->nolist = nolist;
 	    s->acc = menuacc;
 	    s->brbeg = dupbrinfo(brbeg, NULL, 1);
 	    s->brend = dupbrinfo(brend, NULL, 1);
@@ -2305,7 +2312,7 @@
 		break;
 
 	    handleundo();
-	    cs = nolist = 0;
+	    cs = 0;
 	    foredel(ll);
 	    spaceinline(l = strlen(u->line));
 	    strncpy((char *) line, u->line, l);
@@ -2336,6 +2343,7 @@
 	    origll = u->origll;
             strcpy(status, u->status);
             mode = u->mode;
+            nolist = u->nolist;
 
 	    u = u->prev;
 	    clearlist = 1;
@@ -2343,6 +2351,16 @@
 	    listdat.valid = 0;
             molbeg = -42;
 
+            if (nolist) {
+                if (mode == MM_INTER) {
+                    statusline = status;
+                    statusll = strlen(status);
+                }
+                zrefresh();
+                statusline = NULL;
+                statusll = 0;
+                goto getk;
+            }
             if (mode)
                 continue;
 	} else if (cmd == Th(z_redisplay)) {
@@ -2781,13 +2799,15 @@
     mselect = mlastcols = mlastlines = -1;
     mstatus = NULL;
     inselect = mhasstat = 0;
+    if (nolist)
+        clearlist = listshown = 1;
     if (acc && validlist && minfo.cur) {
 	menucmp = lastambig = hasoldlist = 0;
 	do_single(*(minfo.cur));
     }
     if (wasnext || broken) {
 	menucmp = 2;
-	showinglist = (validlist ? -2 : 0);
+	showinglist = ((validlist && !nolist) ? -2 : 0);
 	minfo.asked = 0;
 	if (!noselect) {
 	    int nos = noselect;
@@ -2797,10 +2817,10 @@
 	}
     }
     if (!noselect && (!dat || acc)) {
-	showinglist = (validlist ? -2 : 0);
+	showinglist = ((validlist && !nolist) ? -2 : 0);
 	onlyexpl = oe;
 	if (!smatches)
-	    clearlist = 1;
+	    clearlist = listshown = 1;
 	zrefresh();
     }
     mlbeg = -1;

-- 
Sven Wischnowsky                          wischnow@berkom.de


  reply	other threads:[~2002-07-05  8:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15642.49846.468542.689062@wischnow.berkom.de>
     [not found] ` <20020627182621.70670.qmail@web10405.mail.yahoo.com>
2002-07-03  7:58   ` Sven Wischnowsky
2002-07-04  9:27     ` Sven Wischnowsky
2002-07-04 17:56       ` Felix Rosencrantz
2002-07-05  8:09         ` Sven Wischnowsky [this message]
2002-07-24 23:01           ` Felix Rosencrantz
2002-07-30  7:47             ` Sven Wischnowsky
2002-06-18  7:57 Sven Wischnowsky
2002-06-18  9:51 ` Oliver Kiddle
2002-06-19  7:49   ` Sven Wischnowsky
2002-06-20 15:52     ` Oliver Kiddle
2002-06-20 15:58       ` Bart Schaefer
2002-06-20 16:22         ` Oliver Kiddle
2002-06-21  9:27       ` Sven Wischnowsky
2002-06-26 10:18         ` Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2002-05-28  8:31 Sven Wischnowsky
2002-05-28 10:44 ` Oliver Kiddle
2002-05-28 11:24   ` Sven Wischnowsky
2002-05-28 12:08 ` Peter Stephenson
2002-05-29 11:23   ` Sven Wischnowsky
2002-05-29 11:30     ` Peter Stephenson
2002-05-29 16:44 ` Felix Rosencrantz

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=15653.21535.954397.86417@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --cc=zsh-workers@sunsite.dk \
    /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).