Skip to content

Commit

Permalink
gptel-context: Fix context inspection buffer issues (#482)
Browse files Browse the repository at this point in the history
* gptel-context.el (gptel-context-confirm, gptel-context-visit):
- Refresh the context buffer when confirming deletions.
- Jump to files correctly when calling `gptel-context-visit'.
  • Loading branch information
karthink committed Nov 24, 2024
1 parent 8fc6c28 commit 11612b9
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions gptel-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,15 @@ If non-nil, indicates backward movement.")
"Display the location of this gptel context chunk in its original buffer."
(interactive)
(let ((ov-here (car (overlays-at (point)))))
(if-let* ((orig-ov (overlay-get ov-here 'gptel-context))
(buf (overlay-buffer orig-ov))
(if-let* ((source (overlay-get ov-here 'gptel-context))
(buf (if (overlayp source)
(overlay-buffer source)
(find-file-noselect source)))
(offset (- (point) (overlay-start ov-here))))
(with-selected-window (display-buffer buf)
(goto-char (overlay-start orig-ov))
(goto-char (if (overlayp source)
(overlay-start source)
(point-min)))
(forward-char offset)
(recenter))
(message "No source location for this gptel context chunk."))))
Expand Down Expand Up @@ -537,12 +541,16 @@ If non-nil, indicates backward movement.")
"Confirm pending operations and return to gptel's menu."
(interactive)
;; Delete all the context overlays that have been marked for deletion.
(mapc #'gptel-context-remove
(delq nil (mapcar (lambda (ov)
(and
(overlay-get ov 'gptel-context-deletion-mark)
(overlay-get ov 'gptel-context)))
(overlays-in (point-min) (point-max)))))
(when-let ((deletion-marks
(delq nil (mapcar
(lambda (ov)
(and
(overlay-get ov 'gptel-context-deletion-mark)
(overlay-get ov 'gptel-context)))
(overlays-in (point-min) (point-max))))))
(mapc #'gptel-context-remove deletion-marks)
(gptel-context--collect) ;Update contexts and revert buffer (#482)
(revert-buffer))
(gptel-context-quit))

(provide 'gptel-context)
Expand Down

0 comments on commit 11612b9

Please sign in to comment.