]> code.delx.au - gnu-emacs/commitdiff
Fix bug #19157 with incorrect hscroll during I-search.
authorEli Zaretskii <eliz@gnu.org>
Mon, 24 Nov 2014 13:32:14 +0000 (15:32 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 24 Nov 2014 13:32:14 +0000 (15:32 +0200)
 lisp/isearch.el (isearch-update): Don't assume
 pos-visible-in-window-p will return nil when point is hscrolled
 out of view.

lisp/ChangeLog
lisp/isearch.el

index c3a01dac664853f28307e7cfdc9a8b719bff8471..26376afe239d15809bf81f9dbca5bd8aefdb7182 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-24  Eli Zaretskii  <eliz@gnu.org>
+
+       * isearch.el (isearch-update): Don't assume
+       pos-visible-in-window-p will return nil when point is hscrolled
+       out of view.  (Bug#19157)
+
 2014-11-20  Andrey Kotlarski  <m00naticus@gmail.com>
 
        * net/eww.el (eww-browse-url): Optionally create new eww buffer.
index f0ce7050e7856e8812ef095e44e88f351f470168..c3e473a2ba6c9328407ea1148df3b94c4f7a700d 100644 (file)
@@ -974,10 +974,17 @@ The last thing it does is to run `isearch-update-post-hook'."
                 (other-window 1))
               (goto-char found-point))
          ;; Keep same hscrolling as at the start of the search when possible
-         (let ((current-scroll (window-hscroll)))
+         (let ((current-scroll (window-hscroll))
+               visible-p)
            (set-window-hscroll (selected-window) isearch-start-hscroll)
-           (unless (pos-visible-in-window-p)
-             (set-window-hscroll (selected-window) current-scroll))))
+           (setq visible-p (pos-visible-in-window-p nil nil t))
+           (if (or (not visible-p)
+                   ;; When point is not visible because of hscroll,
+                   ;; pos-visible-in-window-p returns non-nil, but
+                   ;; the X coordinate it returns is 1 pixel beyond
+                   ;; the last visible one.
+                   (>= (car visible-p) (window-body-width nil t)))
+               (set-window-hscroll (selected-window) current-scroll))))
        (if isearch-other-end
             (if (< isearch-other-end (point)) ; isearch-forward?
                 (isearch-highlight isearch-other-end (point))