From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3792 invoked by alias); 27 Jul 2015 15:50:51 -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: 35935 Received: (qmail 16204 invoked from network); 27 Jul 2015 15:50:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1438011896; bh=Z/XgLB1mOErEVOygqMofMTAovIbTkNIx7hdAbmqAa8s=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=sfdzWip1GLR2pal8+VKq7y9NoeuRDII0KQarBGE4Dx5A251oD3gYTMgzU3CJ7NzHAjG5jqFkAgk1sEQ9ZN56t8o1/W4/ff57tDAnZj280UMQOWWPv4pQUnlisR47StHpyDNA+aGNUQmLe5aa58zXbvNl9NlKi+AAK8Em87Qf/pQSBi6wzC5PFxYVU0l9WUSSLuEQD8st4GLCC0f9nxt4wB+HGfmfB39jIj8pMLw2ilDasG7DHIW9bdQ2Bm2crtG6q21hD8AbcZwgVRAWFAREmjRfxCsO/lIFn0rr9dk03EVnnJebrcF8eLTkL02tyEBUKzKJdgRc7mS1iITorwf6Ew== X-Yahoo-Newman-Id: 325465.49596.bm@smtp112.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: CqWrDWsVM1ntzd71I_ovsTdGZsW9NwnEubyqD59bQ2.ZBkS KLgCikJUOYWtQwi7LaNyTrqGK.nSdJt3522A1l3O5fCu.ThEfHFkosh.2fFY 5T7iczmkX_tCufLkzVadpMzfPBr4RbZfXvcE7vcFgLi5giobUPhEG638f5Me Oloul3sH_LQPa5RoQ.iis7QHuRBNlgoI38E7qf_9GmNy6dJ9VhROR_U9IRal fKZ4wioE7tFpRYLY9VyEXbvt5VeZhtfRcTLZHcgCeO_bUrdEBK00AyQAMFvj 4XkZa46zl90VvjkuRo.TAi5UqnmkwjyTiUnfMio86tFd0JVmmoEQ9oyR9HF_ f8WHk0y7zJIFPFAWZj4fDqSyVB8tQuF1GvfnvI8M8kuHA20UFWKfQY4nnFG_ SWXn7_PvZuH..xWmvaFuiP6mBMwyrrYB8uBULqbHcFcRO5bjb7JLqBTpBfX3 y5SbMdXQgbpyfdSC5LMctBdLuZVaCHj0.YOpBetZUHGWb0rsak.HZcbjGQdI 9JjhC.rCbrtYHEgTNwhmk4PnabMChVg-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <150722224101.ZM14105@torch.brasslantern.com> From: Oliver Kiddle References: <150620102144.ZM5618@torch.brasslantern.com> <150718164224.ZM4759@torch.brasslantern.com> <19747.1437278114@thecus.kiddle.eu> <150719012304.ZM18439@torch.brasslantern.com> <9927.1437383950@thecus.kiddle.eu> <150722224101.ZM14105@torch.brasslantern.com> To: zsh workers Subject: Re: Undo and narrow-to-region (was Re: PATCH: narrow-to-region (was ...)) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29488.1438011895.1@thecus.kiddle.eu> Date: Mon, 27 Jul 2015 17:44:55 +0200 Message-ID: <29489.1438011895@thecus.kiddle.eu> On 22 Jul, Bart wrote: > So you mean that part of undo becomes > > if (unapplychange(prev)) > curchange = prev; > } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV)); > > ?? > > What must be happening is that unapplychange() alters the history line, > returns zero, and then is called again with exactly the same struct, Yes. Changes to the history number are not collected up as change events in nextchanges. This means that several history line changes are undone in a single go. It also has the, perhaps less desirable, effect that you can't use redo to revert a change to the history line. Is that worth fixing? > So the "else break;" looks like paranoia to prevent an infinite loop in > the event that unapplychange() fails every time. Which could happen if > quietgethist() is a no-op? Perhaps when a line has fallen out of the > history because of HISTSIZE? I tried to find a way to induce such an infinite loop and couldn't. Even so, how about the following patch which checks histline had changed to detect a failure to set the history line. > Anyway modulo infinite-loop-prevention, it looks to me as if removing > that else-clause is the right thing to do, and similarly in redo() a > bit further along. I'll let Oliver do the patch if we all agree. Not sure it's necessary for redo because there's no option to redo more than one change. Oliver diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 8b55403..d512c7a 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1590,8 +1590,8 @@ undo(char **args) return 1; if (unapplychange(prev)) curchange = prev; - else - break; + else if (histline != prev->hist) + break; /* avoid infinite loop if history line unchanged */ } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV)); setlastline(); return 0;