Skip to content

Commit d8d4c9c

Browse files
committed
Fix restart
1 parent 96f288e commit d8d4c9c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

chatgpt.el

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,18 @@ Display buffer from BUFFER-OR-NAME."
258258
(defun chatgpt-restart ()
259259
"Restart session."
260260
(interactive)
261-
(let* ((instance chatgpt-instances)
262-
(index (car instance))
263-
(old-name))
264-
;; If buffer is alive, kill it!
265-
(chatgpt-with-instance instance
266-
(setq old-name (buffer-name))
267-
(kill-this-buffer))
268-
;; `old-name' will remain `nil' if buffer is not killed or invalid!
269-
(when old-name
270-
(chatgpt-register-instance index old-name))))
261+
(when (eq major-mode #'chatgpt-mode)
262+
(let* ((instance chatgpt-instance)
263+
(index (car instance))
264+
(old-name))
265+
;; If buffer is alive, kill it!
266+
(chatgpt-with-instance instance
267+
(setq old-name (buffer-name))
268+
(kill-this-buffer))
269+
;; `old-name' will remain `nil' if buffer is not killed or invalid!
270+
(when old-name
271+
(chatgpt-register-instance index old-name)
272+
(switch-to-buffer old-name)))))
271273

272274
;;
273275
;;; Core

0 commit comments

Comments
 (0)