about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-10-09 16:27:11 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-10-09 16:27:11 +0000
commit34ed3eaecd3fedb8733b82c27dccba024608bf5f (patch)
tree43dcf2eb3fd9d3b806dfdb41f94af7cbcc85c3c0 /Src
parent0fda80344b49d952c02721613a17026185c87840 (diff)
downloadzsh-34ed3eaecd3fedb8733b82c27dccba024608bf5f.tar.gz
zsh-34ed3eaecd3fedb8733b82c27dccba024608bf5f.tar.xz
zsh-34ed3eaecd3fedb8733b82c27dccba024608bf5f.zip
users/17318: only increment the undo variable return value for the
first request in a row
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_utils.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 55fd2ffd2..d0e7b5542 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1363,6 +1363,10 @@ static struct change *nextchanges, *endnextchanges;
 
 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