zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: bug in replace-string: widget loses characters
Date: Tue, 9 Oct 2012 17:11:36 +0100	[thread overview]
Message-ID: <CAECNH1RcdSN2uAt6E2erc8AP6nGzAgsO+BP+63bPGoYZKELv_Q@mail.gmail.com> (raw)
In-Reply-To: <20121009164415.1ad853e3@pwslap01u.europe.root.pri>

On 9 October 2012 16:44, Peter Stephenson <p.stephenson@samsung.com> 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


      reply	other threads:[~2012-10-09 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 18:19 Moritz Bunkus
2012-10-09 11:22 ` Peter Stephenson
2012-10-09 11:54   ` Moritz Bunkus
2012-10-09 14:34   ` Peter Stephenson
2012-10-09 15:24     ` Bart Schaefer
2012-10-09 15:44       ` Peter Stephenson
2012-10-09 16:11         ` 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=CAECNH1RcdSN2uAt6E2erc8AP6nGzAgsO+BP+63bPGoYZKELv_Q@mail.gmail.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /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).