From 0cfc06d09571eb93e02d43fe12828de7e9eb2021 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 29 Apr 2025 19:35:30 +0300 Subject: [PATCH] Respect point when changing direction after isearch scrolling. * lisp/isearch.el (isearch-repeat): Don't go to isearch-other-end on changing direction after scrolling (bug#78074). (cherry picked from commit 622825995204b7aae70b836c8e5e5d44385c401b) --- lisp/isearch.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index aaa3df75a9e..19d13057eff 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1910,7 +1910,14 @@ Use `isearch-exit' to quit without signaling." (funcall isearch-wrap-function) (goto-char (if isearch-forward (point-min) (point-max)))))) ;; C-s in reverse or C-r in forward, change direction. - (if (and isearch-other-end isearch-repeat-on-direction-change) + (if (and isearch-other-end isearch-repeat-on-direction-change + (or (null isearch-cmds) + ;; Go to 'isearch-other-end' only when point is still + ;; on the current match. However, after scrolling + ;; (when 'isearch-allow-scroll' is 'unlimited'), + ;; repeat the reversed search from a new position + ;; where point was moved during scrolling (bug#78074). + (eq (isearch--state-point (car isearch-cmds)) (point)))) (goto-char isearch-other-end)) (setq isearch-forward (not isearch-forward) isearch-success t)) -- 2.39.5