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

PATCH: save last position in vi-goto-mark



This actually backs out some of 28611 so perhaps this once worked in the
distant past. `` or '' should return to the previous position from before the
last jump. The rather pointless `' and '` will also do the same but they do in
vim too. I suspect that with the original implementation, LASTFULLCHAR was
returning ` or ' and avoiding this quirk but it now returns the character of
the recently set mark (hence the bug that 28611 fixed). The code for saving the
old position must have either got lost or was forgotten in the first place.

Oliver

diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index 4653855..73c8e59 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -30,7 +30,7 @@
 #include "zle.mdh"
 #include "zle_move.pro"
 
-static int vimarkcs[26], vimarkline[26];
+static int vimarkcs[27], vimarkline[27];
 
 #ifdef MULTIBYTE_SUPPORT
 /*
@@ -834,11 +834,17 @@ int
 vigotomark(UNUSED(char **args))
 {
     ZLE_INT_T ch;
+    int oldcs = zlecs;
+    int oldline = histline;
 
     ch = getfullchar(0);
-    if (ch < ZWC('a') || ch > ZWC('z'))
-	return 1;
-    ch -= ZWC('a');
+    if (ch == ZWC('\'') || ch == ZWC('`'))
+	ch = 26;
+    else {
+	if (ch < ZWC('a') || ch > ZWC('z'))
+	    return 1;
+	ch -= ZWC('a');
+    }
     if (!vimarkline[ch])
 	return 1;
     if (curhist != vimarkline[ch] && !zle_goto_hist(vimarkline[ch], 0, 0)) {
@@ -846,6 +852,8 @@ vigotomark(UNUSED(char **args))
 	return 1;
     }
     zlecs = vimarkcs[ch];
+    vimarkcs[26] = oldcs;
+    vimarkline[26] = histline;
     if (zlecs > zlell)
 	zlecs = zlell;
     return 0;



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