From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9483 invoked by alias); 8 Jan 2017 17:59:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40305 Received: (qmail 28225 invoked from network); 8 Jan 2017 17:59:20 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-3.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.67):SA:0(-1.2/5.0):. Processed in 1.342878 secs); 08 Jan 2017 17:59:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.67 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=AtwTp7JP c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=sDS6MaYEI7GgP5QO4IMA:9 a=3Rk4rcrKracCGhTA:21 a=3vVjkZFfMabZXJl8:21 a=CjuIK1q_8ugA:10 a=z9dJwno5l634igLiVhy-:22 Date: Sun, 8 Jan 2017 17:59:09 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: 'zle redisplay' bug in 5.3? Message-ID: <20170108175909.7c03f053@ntlworld.com> In-Reply-To: <170107204640.ZM12937@torch.brasslantern.com> References: <20170105030137.v4tzweda6pxyqnrq@majutsushi.net> <170105010914.ZM1529@torch.brasslantern.com> <20170105150135.75a490bb@pwslap01u.europe.root.pri> <170105090803.ZM3653@torch.brasslantern.com> <170107100505.ZM11210@torch.brasslantern.com> <20170107185325.061a57cf@ntlworld.com> <20170107200455.656cec0c@ntlworld.com> <170107204640.ZM12937@torch.brasslantern.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 7 Jan 2017 20:46:40 -0800 Bart Schaefer wrote: > On Jan 7, 8:04pm, Peter Stephenson wrote: > } Subject: Re: 'zle redisplay' bug in 5.3? > } > } OK, how about this as an alternative to the previous change to the > } refresh code? If I'm following properly, this was a problem when > } > } TRAPINT () { > } zle reset-prompt > } return 127 > } } > } > } was in effect during interruption at a completion list. > > That's correct. However, this patch (checking errflag) does not fix > the issue with interrupts. There isn't a *the* issue, is there? There can't be; the interrupt can go off absolutely anywhere. I've fixed the one with complist, which is what was originally reported, now you're saying there's something else... > autoload compinit > compinit -u -D > TRAPINT () { > zle reset-prompt > return 127 > } > _delay() { sleep 10 } > zstyle \* completer _complete _delay > > Now complete after e.g. "ls " and press ^C within 10 seconds. The > complist module does not need to be involved, so a change only there > does not help. That is indeed a completely different problem, at least the problem that shows up when I try this certainly is. I'm not sure the _delay has got much to do with it, though, so it's possible there's yet more. We're not actually in or under completion code here --- though the hook mechanism makes that statement less useful than it might otherwise be. However, that does mean that in this case we're not aborting a display --- we're aborting to a new command line. (That's the same as if you just do the straight compinit then the same key sequence, but the modification of the completer means that you ought to look at the internal state when the interrupt happens to confirm, which I've done.) It turns out the prompt doesn't get redrawn on that line because clearflag isn't initialised to zero, even though it's value is meaningless when we restart ZLE for the new line as we should redraw everything from scratch --- that's the residual effect of the completion code's hook using dolastprompt, I think. It looks like the line we're aborting isn't completely tidied up, either, there's a bit of stray output from the reset-prompt, but I consider that very minor as we're aborting it completely, and separate again. I intend to commit this. Please we can take problems one at a time? diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 2edaf6e..0350388 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1993,7 +1993,8 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) if (noselect > 0) noselect = 0; - if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines) { + if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines || + errflag) { showinglist = 0; amatches = oamatches; return (noselect = 1); diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 15ea796..6c271b5 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1245,6 +1245,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) resetneeded = 0; fetchttyinfo = 0; trashedzle = 0; + clearflag = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL, &pmpt_attr); raw_rp = rp; diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 8d173cd..8391739 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -2434,8 +2434,8 @@ redisplay(UNUSED(char **args)) moveto(0, 0); zputc(&zr_cr); /* extra care */ tc_upcurs(lprompth - 1); - resetneeded = !showinglist; - clearflag = showinglist; + resetneeded = 1; + clearflag = 0; return 0; } diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index c709285..c003148 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -703,7 +703,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) { Thingy t; struct modifier modsave = zmod; - int ret, saveflag = 0, setbindk = 0; + int ret, saveflag = 0, setbindk = 0, remetafy; char *wname = *args++, *keymap_restore = NULL, *keymap_tmp; if (!wname) @@ -714,7 +714,15 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) return 1; } - UNMETACHECK(); + /* + * zle is callable in traps, so we can't be sure the line is + * in its normal state. + */ + if (zlemetaline) { + unmetafy_line(); + remetafy = 1; + } else + remetafy = 0; while (*args && **args == '-') { char *num; @@ -728,6 +736,8 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) num = args[0][1] ? args[0]+1 : args[1]; if (!num) { zwarnnam(name, "number expected after -%c", **args); + if (remetafy) + metafy_line(); return 1; } if (!args[0][1]) @@ -745,19 +755,26 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) keymap_tmp = args[0][1] ? args[0]+1 : args[1]; if (!keymap_tmp) { zwarnnam(name, "keymap expected after -%c", **args); + if (remetafy) + metafy_line(); return 1; } if (!args[0][1]) *++args = "" - 1; keymap_restore = dupstring(curkeymapname); - if (selectkeymap(keymap_tmp, 0)) + if (selectkeymap(keymap_tmp, 0)) { + if (remetafy) + metafy_line(); return 1; + } break; case 'w': setbindk = 1; break; default: zwarnnam(name, "unknown option: %s", *args); + if (remetafy) + metafy_line(); return 1; } } @@ -775,6 +792,8 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) zmod = modsave; if (keymap_restore) selectkeymap(keymap_restore, 0); + if (remetafy) + metafy_line(); return ret; }