zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: menu-select crashes and redraw problems
Date: Thu, 28 Feb 2008 23:10:25 +0000	[thread overview]
Message-ID: <20080228231025.2eb9715a@pws-pc> (raw)
In-Reply-To: <237967ef0712222224y3acd07c4oe6843d366f763b25@mail.gmail.com>

On Sun, 23 Dec 2007 07:24:48 +0100
"Mikael Magnusson" <mikachu@gmail.com> wrote:
> When i use menu-select and resize the terminal while the select is
> going on (no, I don't usually do this :) ), zsh usually crashes after
> a couple of tries. It almost always messes up the display of the list
> after a resize, sometimes it fixes itself when you scroll around,
> sometimes not. I reproduced it with zsh -f like this
> 
> zsh -f
> zmodload zsh/complist
> ls <alt-x>menu-select<enter>
> <scroll around a bit, preferably to a second or higher column>*
> <resize terminal narrower so the column with the cursor disappears>
> <scroll around a bit more>
> <repeat from * until zsh crashes>

After an hour or two chasing red herrings around gum trees, I came up
with this.  It's not the end of the story, since the display seems to
get messed up occasionally, but it does seem to reduce or possibly
eliminate crashes.  This is one of those "please don't ask me what it
does" fixes, but I think the story is cases like this are mostly handled
and it simply didn't try quite as hard as it could to fix up lines and
columns.

I suspect that in principle there are horrific races such that if
SIGWINCH arrives when the code is anywhere other than waiting for a key
press pretty much anything can happen.  I am successfully ignoring this
so far and hope to continue doing so.

As you'll see in the first hunk, I've added a detailed explanatory
comment to one of the many sophisticated features of the code.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.107
diff -u -r1.107 complist.c
--- Src/Zle/complist.c	15 Feb 2008 22:01:05 -0000	1.107
+++ Src/Zle/complist.c	28 Feb 2008 22:51:40 -0000
@@ -122,7 +122,11 @@
 int mgtabsize;
 #endif
 
-/* Used in mtab/mgtab, for explanations. */
+/*
+ * Used in mtab/mgtab, for explanations.
+ *
+ * UUUUUUUUUUUUUUURRRRGHHHHHHHHHH!!!!!!!!! --- pws
+ */
 
 #define MMARK       ((unsigned long) 1)
 #define mmarked(v)  (((unsigned long) (v)) & MMARK)
@@ -2325,8 +2329,7 @@
     for (;;) {
 	METACHECK();
 
-    	mtab_been_reallocated = 0;
-	if (mline < 0) {
+	if (mline < 0 || mtab_been_reallocated) {
 	    int x, y;
 	    Cmatch **p = mtab;
 
@@ -2342,6 +2345,7 @@
 	    if (y < mlines)
 		mline = y;
 	}
+    	mtab_been_reallocated = 0;
 	DPUTS(mline < 0,
 	      "BUG: mline < 0 after re-scanning mtab in domenuselect()");
 	while (mline < mlbeg)


-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2008-02-28 23:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-23  6:24 Mikael Magnusson
2008-02-28 23:10 ` Peter Stephenson [this message]

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=20080228231025.2eb9715a@pws-pc \
    --to=p.w.stephenson@ntlworld.com \
    --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).