Subject: bug#19353: 25.0.50; Lazy Highlighting

From: Juri Linkov <[email-masked]>
Date: Fri, 12 Dec 2014 02:18:10 +0200

> Recipe:
> 0. emacs -Q
> 1. Create and empty buffer.
> 2. Write there this text (without the hyphen lines):
> --------------
> fat cat path
> too book cool
> --------------
> 3. Place point just after the "a" in "path".
> 4. Type: C-s a t

> 5. Place point just after the first "o" in "cool".
> 6. Type: C-s o o

Does this patch address all your test cases?  It prolongs the
boundary of the wrapped search by the length of the search string,
and in the worst case it might lazy-highlight some matches twice.

diff --git a/lisp/isearch.el b/lisp/isearch.el
index c3e473a..5fb687b 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -3063,11 +3063,13 @@ (defun isearch-lazy-highlight-search ()
 	    (bound (if isearch-lazy-highlight-forward
 		       (min (or isearch-lazy-highlight-end-limit (point-max))
 			    (if isearch-lazy-highlight-wrapped
-				isearch-lazy-highlight-start
+				(+ isearch-lazy-highlight-start
+				   (1- (length isearch-lazy-highlight-last-string)))
 			      (window-end)))
 		     (max (or isearch-lazy-highlight-start-limit (point-min))
 			  (if isearch-lazy-highlight-wrapped
-			      isearch-lazy-highlight-end
+			      (- isearch-lazy-highlight-end
+				 (1- (length isearch-lazy-highlight-last-string)))
 			    (window-start))))))
 	;; Use a loop like in `isearch-search'.
 	(while retry