Skip to content

Commit c0f0555

Browse files
committed
Don't move to bob/eob if wrapping enabled and no matches
Closes #67.
1 parent e0ba3e1 commit c0f0555

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: hl-todo.el

+12-6
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,12 @@ A negative argument means move backward that many keywords."
296296
(user-error "No more matches")))))
297297
(cl-decf arg))
298298
(when (> arg 0)
299-
(goto-char (point-min))
300-
(let ((hl-todo-wrap-movement nil))
301-
(hl-todo-next arg)))))
299+
(let ((pos (save-excursion
300+
(goto-char (point-min))
301+
(let ((hl-todo-wrap-movement nil))
302+
(hl-todo-next arg))
303+
(point))))
304+
(goto-char pos)))))
302305

303306
;;;###autoload
304307
(defun hl-todo-previous (arg)
@@ -320,9 +323,12 @@ A negative argument means move forward that many keywords."
320323
(goto-char (match-end 0))
321324
(cl-decf arg))
322325
(when (> arg 0)
323-
(goto-char (point-max))
324-
(let ((hl-todo-wrap-movement nil))
325-
(hl-todo-previous arg)))))
326+
(let ((pos (save-excursion
327+
(goto-char (point-max))
328+
(let ((hl-todo-wrap-movement nil))
329+
(hl-todo-previous arg))
330+
(point))))
331+
(goto-char pos)))))
326332

327333
;;;###autoload
328334
(defun hl-todo-occur ()

0 commit comments

Comments
 (0)