about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-11-05 22:50:48 +0100
committerOliver Kiddle <opk@zsh.org>2014-11-05 22:50:48 +0100
commitc7ff843ecf60ab74ce98929e45029b1aef5014e1 (patch)
treea8fdeed6b399dd36c055e7030ccad10df1b1528a
parent4b66ec003ff0631e39240576920dda971d555f6d (diff)
downloadzsh-c7ff843ecf60ab74ce98929e45029b1aef5014e1.tar.gz
zsh-c7ff843ecf60ab74ce98929e45029b1aef5014e1.tar.xz
zsh-c7ff843ecf60ab74ce98929e45029b1aef5014e1.zip
33604: fix change merging for vi mode where a change has just been undone
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_utils.c6
-rw-r--r--Src/Zle/zle_vi.c4
-rw-r--r--Test/X02zlevi.ztst6
4 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b17490cf..cb739d5a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-05  Oliver Kiddle  <opk@zsh.org>
+
+	* 33604: Src/Zle/zle_utils.c, Src/Zle/zle_vi.c, Test/X02zlevi.ztst:
+	fix change merging for vi mode where a change has just been undone
+
 2014-11-04  Oliver Kiddle  <opk@zsh.org>
 
 	* 33596: Src/Zle/zle_keymap.c: make local keymap keybinding hide
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 741f119d2..e95a34b95 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 18c76f917..d74b40d62 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 f8a94ce3d..561a5fd73 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