about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle_main.c2
-rw-r--r--Src/Zle/zle_utils.c26
-rw-r--r--Src/Zle/zle_vi.c8
5 files changed, 37 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index a5be39298..de6aa34db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-02-05  Oliver Kiddle <opk@zsh.org>
+
+	* 32334 (modified so KEEPSUFFIX is unchanged for vi-cmd-mode; based on
+	Jun T: 32324, 32330), 32347, Jun T: 32344, 32349: Src/Zle/iwidgets.list,
+	Src/Zle/zle_main.c, Src/Zle/zle_utils.c, Src/Zle/zle_vi.c
+	add split-undo zle widget for configurable breaks in undo sequence
+
 2014-02-02  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* unposted: Doc/Zsh/builtins.yo, Doc/Zsh/expn.yo,
@@ -20,7 +27,7 @@
 	unset for better compatibility in emulation modes; for the same
 	reason, remove the readonly flag from $_
 
-2013-02-27  Oliver Kiddle <opk@zsh.org>
+2014-01-31  Oliver Kiddle <opk@zsh.org>
 
 	* 32314: Src/Zle/zle_main.c, Src/Zle/zle_tricky.c,
 	Src/Zle/zle_utils.c, Src/Zle/zle_vi.c: merge undo events
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index 4372fe36e..e3ffe3e8c 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -102,6 +102,7 @@
 "self-insert-unmeta", selfinsertunmeta, ZLE_MENUCMP | ZLE_KEEPSUFFIX
 "send-break", sendbreak, 0
 "set-mark-command", setmarkcommand, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
+"split-undo", splitundo, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_NOTCOMMAND
 "spell-word", spellword, 0
 "set-local-history", setlocalhistory, 0
 "transpose-chars", transposechars, 0
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index f5aec8403..ed8577bcd 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1189,7 +1189,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish)
     zlereadflags = flags;
     zlecontext = context;
     histline = curhist;
-    vistartchange = 0;
+    vistartchange = -1;
     zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE);
     *zleline = ZWC('\0');
     virangeflag = lastcmd = done = zlecs = zlell = mark = 0;
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 61ae85c0b..9cfa8813d 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1632,6 +1632,32 @@ viundochange(char **args)
 	return undo(args);
 }
 
+/**/
+int
+splitundo(char **args)
+{
+    if (vistartchange >= 0) {
+	mergeundo();
+	vistartchange = (curchange && curchange->prev) ?
+	    curchange->prev->changeno : 0;
+    }
+    handleundo();
+    return 0;
+}
+
+/**/
+void
+mergeundo(void)
+{
+    struct change *current;
+    for (current = curchange->prev;
+	    current && current->prev && current->changeno > vistartchange+1;
+	    current = current->prev) {
+	current->flags |= CH_PREV;
+	current->prev->flags |= CH_NEXT;
+    }
+}
+
 /*
  * Call a ZLE hook: a user-defined widget called at a specific point
  * within the line editor.
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 9e9cc2f34..79b8cb958 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -584,13 +584,7 @@ vicmdmode(UNUSED(char **args))
 {
     if (invicmdmode() || selectkeymap("vicmd", 0))
 	return 1;
-    struct change *current = curchange->prev;
-    while (current && current->changeno > vistartchange+1) {
-	current->flags |= CH_PREV;
-	current = current->prev;
-	if (!current) break;
-	current->flags |= CH_NEXT;
-    }
+    mergeundo();
     vichgflag = 0;
     if (zlecs != findbol())
 	DECCS();