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

Re: PATCH: pattern incremental search



Peter Stephenson wrote:
> I think this is now good enough for some beta testing, though I'm sure
> there must be glitches.

Just discovered this.  I hope this is the right fix.

Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.44
diff -u -r1.44 zle_hist.c
--- Src/Zle/zle_hist.c	26 Apr 2008 19:51:09 -0000	1.44
+++ Src/Zle/zle_hist.c	26 Apr 2008 20:21:50 -0000
@@ -1074,6 +1074,14 @@
      */
     int revert_patpos = 0;
     /*
+     * Another nasty feature related to the above.  When
+     * we revert the position, we might advance the search to
+     * the same line again.  When we do this the test for ignoring
+     * duplicates may trigger.  This flag indicates that in this
+     * case it's OK.
+     */
+    int dup_ok = 0;
+    /*
      * savekeys records the unget buffer, so that if we have arguments
      * they don't pollute the input.
      * feep indicates we should feep.  This is a well-known word
@@ -1219,6 +1227,7 @@
 				     * search started; see note above.
 				     */
 				    revert_patpos = 0;
+				    dup_ok = 1;
 				    he = quietgethist(hl = pat_hl);
 				    zt = GETZLETEXT(he);
 				    pos = pat_pos;
@@ -1322,10 +1331,14 @@
 		hl = he->histnum;
 		zt = GETZLETEXT(he);
 		pos = (dir == 1) ? 0 : strlen(zt);
-		skip_line = isset(HISTFINDNODUPS)
-		    ? !!(he->node.flags & HIST_DUP)
-		    : !strcmp(zt, last_line);
+		if (dup_ok)
+		    skip_line = 0;
+		else
+		    skip_line = isset(HISTFINDNODUPS)
+			? !!(he->node.flags & HIST_DUP)
+			: !strcmp(zt, last_line);
 	    }
+	    dup_ok = 0;
 	    /*
 	     * If we matched above (t set), set the new line.
 	     * If we didn't, but are here because we are on a previous


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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