Skip to content

Commit b693bec

Browse files
committed
gptel: Move auto-scroll delay up to the outside
* gptel.el (gptel-auto-scroll): Move run-at-time to the "outside" of the scroll command, to capture the condition-case.
1 parent 0f509e9 commit b693bec

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gptel.el

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,14 @@ Later plists in the sequence take precedence over earlier ones."
10091009
"Scroll window if LLM response continues below viewport.
10101010
10111011
Note: This will move the cursor."
1012-
(when-let* ((win (get-buffer-window (current-buffer) 'visible))
1013-
((not (pos-visible-in-window-p (point) win)))
1014-
(scroll-error-top-bottom t))
1015-
(condition-case nil
1016-
(with-selected-window win
1017-
(run-at-time 0 nil #'scroll-up-command))
1018-
(error nil))))
1012+
(run-at-time ;Scheduled on the event loop to call from outside save-excursion
1013+
0 nil (lambda ()
1014+
(when-let* ((win (get-buffer-window (current-buffer) 'visible))
1015+
((not (pos-visible-in-window-p (point) win)))
1016+
(scroll-error-top-bottom t))
1017+
(condition-case nil
1018+
(with-selected-window win (scroll-up-command))
1019+
(error nil))))))
10191020

10201021
(defun gptel-beginning-of-response (&optional _ _ arg)
10211022
"Move point to the beginning of the LLM response ARG times."

0 commit comments

Comments
 (0)