Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix merging of undo events
- X-seq: zsh-workers 33604
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: fix merging of undo events
- Date: Wed, 05 Nov 2014 18:27:50 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1415208472; bh=RBll+X7kE0yT9B6iHMTzbbLZ8hwHi9knKn8zyR12LgQ=; h=From:To:Subject:Date:From:Subject; b=k3S6b+E7FMjIN3eov2mNj/r2fQdpQdO/qCOl8Yr4Rm9dmVZ1JUYy/By3jfohvKFs9Pt8I4oKbBSeu5e2V1f0RIhiiIg9Mzm1PyFyDeRA52XSeIxyVTq6W0McV3Q1nASws9LMSly4TBEt5for2wkPhYukWpljWfw0FtpOqcIRUU4QAhx90EisAwrOY4Um6pIbn82AnmNXnjPMrPiv9T1O18S+hXZUV/HHNqzzdWrCsCi/eREih6dXp24KtVEYF6faOnDK6iKwsrNHNjE1kcNKaDqgRbMdmYI8VtHvAbkMU02a8Qb9bNMdqaODqt6hLDG9nTAp0OLrQXIb0fsMauTg6Q==
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=mwc6zunzq/H1xyEU3UW8N1m+9rMfEj6SWUEnjurZILu0mphlkegCwxJ3fv5yrgorAZXLCeMonpnHGFswqf4UGXVXAwSypHzhgBdbAKlEC98pYP5XQXX2ofR9qGAzgZukhHI2dczWttKVa11zAlYqqU2qkVxZpGgT+iE3HpVFJWHCkHaphyRl9O1K0dLPpq5ynkI1r2hwu6LphR1B7dy4lSJBfkStn6qb7oed65sY6xtad8tGCY/GEhg9/1D6vwWuy5beDd4GNOw0v6feAHzXD6TCpk2uCfxCQXOCpXd+ngBtaflXo3s52/o4wCsF0IEWO0mQtUfXuVWElzGiMQqd/Q==;
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This fixes an issue that I introduced earlier this year in 32314.
It looked at the first undo event to get an undo change number for the
point where change merging should stop. By doing and undoing further
changes, this could have the effect of merging the current event onto
the previous changes.
If the new test case is run in a debugger, the final vi change is at
7, 8 corresponds to a change that has been undone and freed and 9 is
the new change (current->changeno in mergeundo()). So 9>7+1 is true and
change 9 got merged onto 7. Fortunately I had kept my gdb macro for
printing the undo stack.
The fix here is to use the undo_changeno value instead. Up to now that
was declared static.
Oliver
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 741f119..e95a34b 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1395,7 +1395,8 @@ static struct change *nextchanges, *endnextchanges;
/* incremented to provide a unique change number */
-static zlong undo_changeno;
+/**/
+zlong undo_changeno;
/* If non-zero, the last increment to undo_changeno was for the variable */
@@ -1668,8 +1669,7 @@ splitundo(char **args)
{
if (vistartchange >= 0) {
mergeundo();
- vistartchange = (curchange && curchange->prev) ?
- curchange->prev->changeno : 0;
+ vistartchange = undo_changeno;
}
handleundo();
return 0;
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 18c76f9..d74b40d 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -109,7 +109,7 @@ startvitext(int im)
{
startvichange(im);
selectkeymap("main", 1);
- vistartchange = (curchange && curchange->prev) ? curchange->prev->changeno : 0;
+ vistartchange = undo_changeno;
viinsbegin = zlecs;
}
@@ -403,7 +403,7 @@ vichange(UNUSED(char **args))
forekill(c2 - zlecs, CUT_RAW);
selectkeymap("main", 1);
viinsbegin = zlecs;
- vistartchange = (curchange && curchange->prev) ? curchange->prev->changeno : 0;
+ vistartchange = undo_changeno;
}
return ret;
}
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index f8a94ce..561a5fd 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -207,6 +207,12 @@
>BUFFER: pre
>CURSOR: 2
+ zletest $'two\eOone\eo\euo\eu'
+0:undo starting with a next change in the change list
+>BUFFER: one
+>two
+>CURSOR: 2
+
zpty_run 'bindkey "^Gu" split-undo'
zletest $'one\C-gutwo\eu'
0:split the undo sequence
Messages sorted by:
Reverse Date,
Date,
Thread,
Author