emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ellama 02bb628778 5/8: Fix bug wrong clearing session


From: ELPA Syncer
Subject: [elpa] externals/ellama 02bb628778 5/8: Fix bug wrong clearing session
Date: Fri, 19 Jan 2024 18:58:00 -0500 (EST)

branch: externals/ellama
commit 02bb628778569993c250b0153db93ce70e7b24b5
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>

    Fix bug wrong clearing session
---
 ellama.el | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/ellama.el b/ellama.el
index 5f20aaa46c..ae98e9e87c 100644
--- a/ellama.el
+++ b/ellama.el
@@ -401,13 +401,21 @@ Provided PROVIDER and PROMPT will be used in new session."
 
 (advice-add #'keyboard-quit :before #'ellama--cancel-current-request)
 
-(defun ellama--session-deactivate (&rest _)
-  "Deactivate current session."
-  (when ellama--current-session
-    (let ((id (ellama-session-id ellama--current-session)))
+(defun ellama--session-deactivate (&rest args)
+  "Deactivate current session with ARGS."
+  (when-let* ((buf (car args))
+             (session
+              (with-current-buffer buf
+                ellama--current-session))
+             (id (ellama-session-id session)))
+    (when (string= (if (bufferp buf)
+                      (buffer-name buf)
+                    buf)
+                  (buffer-name (ellama-get-session-buffer id)))
+      (message "clearing %s" id)
+      (remhash id ellama--active-sessions)
       (when (equal ellama--current-session-id id)
-       (setq ellama--current-session-id nil))
-      (remhash id ellama--active-sessions))))
+       (setq ellama--current-session-id nil)))))
 
 (advice-add #'kill-buffer :before #'ellama--session-deactivate)
 
@@ -594,7 +602,8 @@ when the request completes (with BUFFER current)."
                             (window (get-buffer-window buffer)))
                    (with-selected-window window
                      (goto-char (point-max))
-                     (recenter -1)))))))
+                     (recenter -1)))
+                 (undo-amalgamate-change-group ellama--change-group)))))
        (setq ellama--change-group (prepare-change-group))
        (activate-change-group ellama--change-group)
        (set-marker start point)
@@ -609,7 +618,6 @@ when the request completes (with BUFFER current)."
                                  (lambda (text)
                                    (funcall insert-text text)
                                    (with-current-buffer buffer
-                                     (undo-amalgamate-change-group 
ellama--change-group)
                                      (accept-change-group ellama--change-group)
                                      (spinner-stop)
                                      (funcall donecb text)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]