summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-10-09 14:57:13 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-10-09 14:57:13 +0000
commit0fda80344b49d952c02721613a17026185c87840 (patch)
tree7b6339c5c4c77dc634e097cdf4176f3b7d56dd93 /Src/Zle/zle_utils.c
parent8d9cb7f42e2822a1c776fe1d0c3c0c3c0e6f8cdc (diff)
downloadzsh-0fda80344b49d952c02721613a17026185c87840.tar.gz
zsh-0fda80344b49d952c02721613a17026185c87840.zip
users/17314: ensure an undo change number
uniquely specifies a point in editing history by incrementing the value returned by the variable.
Diffstat (limited to 'Src/Zle/zle_utils.c')
-rw-r--r--Src/Zle/zle_utils.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index cf6787f3a..55fd2ffd2 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1520,23 +1520,25 @@ setlastline(void)
int
undo(char **args)
{
- zlong last_change = (zlong)0;
+ zlong last_change;
if (*args)
- {
last_change = zstrtol(*args, NULL, 0);
- }
+ else
+ last_change = (zlong)-1;
handleundo();
do {
- if(!curchange->prev)
+ struct change *prev = curchange->prev;
+ if(!prev)
return 1;
- if (unapplychange(curchange->prev))
- curchange = curchange->prev;
+ if (prev->changeno < last_change)
+ break;
+ if (unapplychange(prev))
+ curchange = prev;
else
break;
- } while (*args ? curchange->changeno != last_change :
- (curchange->flags & CH_PREV));
+ } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV));
setlastline();
return 0;
}
@@ -1660,6 +1662,11 @@ zlecallhook(char *name, char *arg)
zlong
get_undo_current_change(UNUSED(Param pm))
{
- return undo_changeno;
+ /*
+ * Increment the number in case a change is in progress;
+ * we don't want to back off what's already been done when
+ * we return to this change number. This eliminates any
+ * problem about the point where a change is numbered.
+ */
+ return ++undo_changeno;
}
-