From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2597 invoked by alias); 9 Oct 2012 16:11:43 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17318 Received: (qmail 5349 invoked from network); 9 Oct 2012 16:11:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.214.171 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=wp6dyrPZ+5y8Ulfpf0bpHfdUGQwkawjI+RYMqXC0bFs=; b=VaDqH8KeEMA90FmfCaEGPqTdvnrg43SdqyUZYATC56OgHsAKppGHPPYfw+drjgQGNm xw7BXv1FTHB1bkytV31py5CL/OWIs4l53lD7hx9DnVRhzombimuSp5mL+TGK4uw9B1Km GYieAssF54NqQYA24Upl+wbCdGzpUQEs7uUpFxElz7EvrZ172utn/XJAyOmEIuhBAP2n 1pyJwQSIYEJDTUh625lE8lvNDc8is/+AQj3eMUISMLY37mMHrH+i+vXL7xkCQ5Aitt80 iPgCeU9elkdH3uYKG3mv4BGZFLL9pZ4LpQReGuWtrH6Y6lXbVpqD5/X8ps8a68Bvi6Zz XW9w== MIME-Version: 1.0 X-Originating-IP: [80.239.194.50] In-Reply-To: <20121009164415.1ad853e3@pwslap01u.europe.root.pri> References: <121009082425.ZM29621@torch.brasslantern.com> <20121009164415.1ad853e3@pwslap01u.europe.root.pri> Date: Tue, 9 Oct 2012 17:11:36 +0100 Message-ID: Subject: Re: bug in replace-string: widget loses characters From: Peter Stephenson To: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkHlTa+8NgSnVXmZkKcVpLb1+sZTVC+KZLFbiK6CP1M3R6OGJphb6/9DDj9e3z7+6NGUHzu On 9 October 2012 16:44, Peter Stephenson wrote: > If it seems a preferable way of doing it, it's straightforward to add a > flag saying who last incremented the number, so it only gets incremented > the first time. The change numbers for the edits are hidden, so that > ought to do the trick. Might as well avoid making unnecessary changes, I suppose. Index: Src/Zle/zle_utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v retrieving revision 1.64 diff -p -u -r1.64 zle_utils.c --- Src/Zle/zle_utils.c 9 Oct 2012 14:57:16 -0000 1.64 +++ Src/Zle/zle_utils.c 9 Oct 2012 16:09:22 -0000 @@ -1363,6 +1363,10 @@ static struct change *nextchanges, *endn static zlong undo_changeno; +/* If non-zero, the last increment to undo_changeno was for the variable */ + +static int undo_set_by_variable; + /**/ void initundo(void) @@ -1373,6 +1377,7 @@ initundo(void) curchange->del = curchange->ins = NULL; curchange->dell = curchange->insl = 0; curchange->changeno = undo_changeno = 0; + undo_set_by_variable = 0; lastline = zalloc((lastlinesz = linesz) * ZLE_CHAR_SIZE); ZS_memcpy(lastline, zleline, (lastll = zlell)); lastcs = zlecs; @@ -1498,6 +1503,7 @@ mkundoent(void) ch->prev = NULL; } ch->changeno = ++undo_changeno; + undo_set_by_variable = 0; endnextchanges = ch; } @@ -1662,6 +1668,11 @@ zlecallhook(char *name, char *arg) zlong get_undo_current_change(UNUSED(Param pm)) { + if (undo_set_by_variable) { + /* We were the last to increment this, doesn't need another one. */ + return undo_changeno; + } + undo_set_by_variable = 1; /* * Increment the number in case a change is in progress; * we don't want to back off what's already been done when pws