branch: elpa/aidermacs
commit a4de4114c09286b23049e31c74076c805bb50cc0
Merge: a7f2153452 b3eb5055f0
Author: Kang Tu <tni...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #42 from tninja/kang_feat
    
    fix: Skip buffer switch if already in Aider buffer
---
 aider.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/aider.el b/aider.el
index 8d6e5637bb..f657ca0703 100644
--- a/aider.el
+++ b/aider.el
@@ -203,13 +203,16 @@ If not in a git repository, an error is raised."
 ;;;###autoload
 (defun aider-switch-to-buffer ()
   "Switch to the Aider buffer.
-When `aider--switch-to-buffer-other-frame' is non-nil, open in a new frame."
+When `aider--switch-to-buffer-other-frame' is non-nil, open in a new frame.
+If the current buffer is already the Aider buffer, do nothing."
   (interactive)
-  (if-let ((buffer (get-buffer (aider-buffer-name))))
-      (if aider--switch-to-buffer-other-frame
-          (switch-to-buffer-other-frame buffer)
-        (pop-to-buffer buffer))
-    (message "Aider buffer '%s' does not exist." (aider-buffer-name))))
+  (if (string= (buffer-name) (aider-buffer-name))
+      (message "Already in Aider buffer")
+    (if-let ((buffer (get-buffer (aider-buffer-name))))
+        (if aider--switch-to-buffer-other-frame
+            (switch-to-buffer-other-frame buffer)
+          (pop-to-buffer buffer))
+      (message "Aider buffer '%s' does not exist." (aider-buffer-name)))))
 
 ;; Function to reset the Aider buffer
 ;;;###autoload

Reply via email to