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

PATCH: vi history repetition



This has vi-history-search-{backward,forward} repeat the
last search if the search string is empty.

I had originally intended for this to be an option, but
it was argued that searching for an empty string in history
is less useful than {up,down}-line-or-history.  This is also
more vi-like.

I'm going to commit this since I can't see a need for the
current behavior.

Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.2
diff -u -r1.2 zle_hist.c
--- Src/Zle/zle_hist.c	2001/05/26 20:57:16	1.2
+++ Src/Zle/zle_hist.c	2001/05/29 20:02:43
@@ -950,7 +950,7 @@
 
 /* the last vi search */
 
-static char *visrchstr;
+static char *visrchstr, *vipenultsrchstr;
 static int visrchsense;
 
 /**/
@@ -962,8 +962,12 @@
     Thingy cmd;
     char *okeymap = curkeymapname;
 
+    if (vipenultsrchstr) {
+	zsfree(vipenultsrchstr);
+    }
+
     if (visrchstr) {
-	zsfree(visrchstr);
+	vipenultsrchstr = visrchstr;
 	visrchstr = NULL;
     }
     clearlist = 1;
@@ -990,6 +994,10 @@
 	    	cmd == Th(z_vicmdmode)) {
 	    sbuf[sptr] = 0;
 	    visrchstr = metafy(sbuf + 1, sptr - 1, META_DUP);
+	    if (!strlen(visrchstr)) {
+	        zsfree(visrchstr);
+		visrchstr = vipenultsrchstr;
+	    }
 	    ret = 1;
 	    sptr = 0;
 	} else if(cmd == Th(z_backwarddeletechar) ||



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