branch: elpa/gptel
commit 7a4bd1d4cb06278aca76e0cce0b1b207df365bca
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-context: Remove buffers correctly when removing overlays
* gptel-context.el (gptel-context-remove): When updating
gptel-context after removing overlays, check for entries
corresponding to the overlay's buffer, and not the current buffer.
This fixes an issue where deleting a context chunk from the
context inspection buffer was causing gptel-context to retain an
entry for the corresponding buffer.
---
gptel-context.el | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/gptel-context.el b/gptel-context.el
index 6a09371ffdb..36f0f220473 100644
--- a/gptel-context.el
+++ b/gptel-context.el
@@ -320,14 +320,15 @@ If selection is active, removes all contexts within
selection.
If CONTEXT is a directory, recursively removes all files in it."
(cond
((overlayp context) ;Overlay in buffer
- (delete-overlay context)
- ;; FIXME: Quadratic cost when clearing a bunch of contexts at once
- (unless
- (cl-loop
- for ov in
- (plist-get (alist-get (current-buffer) gptel-context) :overlays)
- thereis (overlay-start ov))
- (setf (alist-get (current-buffer) gptel-context nil 'remove) nil)))
+ (when-let* ((buf (overlay-buffer context)))
+ (delete-overlay context)
+ ;; FIXME: Quadratic cost when clearing a bunch of contexts at once
+ (unless
+ (cl-loop
+ for ov in
+ (plist-get (alist-get buf gptel-context) :overlays)
+ thereis (overlay-start ov))
+ (setf (alist-get buf gptel-context nil 'remove) nil))))
((bufferp context) ;Full buffer
(setf (alist-get context gptel-context nil 'remove) nil)
(when (buffer-live-p context)