Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

vi start of insert is easily broken

In vi mode, it isn't hard to insert text in a position before
viinsbegin. This messes up widgets that stop there.

The default bindings for both left and up cursors happily ignore
viinsbegin. Furthermore, being used to vim, I use the emacs backspace
binding instead of the vi one because it doesn't stop at the line or
insert beginning.

Many cases can be fixed in spaceinline(). The question is, should we
just assign 0 to it or increment it by ct as we do for mark? Should I
apply the patch below (or something similar)?

Emacs style history commands from vi mode also preserve viinsbegin.
Assigning 0 to it in setline as below fixes that but might break a
user-defined widget that assigns to BUFFER. It also stays reset if the
history command is undone. Any thoughts on that?

Zsh also preserves mark when moving between history lines. Is that useful?
That would be harder to fix when accounting for user defined widgets.


diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 46d5373..741f119 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -785,6 +785,8 @@ spaceinline(int ct)
 	if (mark > zlecs)
 	    mark += ct;
+	if (viinsbegin > zlecs)
+	    viinsbegin = 0;
 	if (region_highlights) {
 	    for (rhp = region_highlights + N_SPECIAL_HIGHLIGHTS;
@@ -1104,6 +1106,7 @@ setline(char *s, int flags)
+    viinsbegin = 0;
     zleline = stringaszleline(scp, 0, &zlell, &linesz, NULL);
     if ((flags & ZSL_TOEND) && (zlecs = zlell) && invicmdmode())
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 5845207..dc5fed4 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -198,7 +198,7 @@ set_buffer(UNUSED(Param pm), char *x)
 	setline(x, 0);
     } else
-	zlecs = zlell = 0;
+	viinsbegin = zlecs = zlell = 0;
     menucmp = 0;

Messages sorted by: Reverse Date, Date, Thread, Author