Skip to content

Commit b743d30

Browse files
authored
Enable which-function mode when fetching call-hierarchy.
1 parent 6d86622 commit b743d30

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

gptel-cpp-complete.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
;; ------------------------------------------------------------
8888
;; Helpers
8989
;; ------------------------------------------------------------
90+
(defmacro gptel-cpp-complete--with-which-function-mode (&rest body)
91+
"Execute BODY with `which-function-mode' enabled, then restore original state."
92+
`(let ((enabled (bound-and-true-p which-function-mode)))
93+
(unwind-protect
94+
(progn
95+
(which-function-mode 1)
96+
,@body)
97+
(which-function-mode (if enabled 1 0)))))
98+
9099
(defun gptel-cpp-complete--extract-method-name (func-name)
91100
"Given FUNC-NAME, return a SHORT-FUNC, e.g: class::method(arg1, arg2) => method."
92101
(when-let* ((temp-split (split-string func-name "("))
@@ -249,7 +258,8 @@
249258
(defun gptel-cpp-complete--call-hierarchy-item ()
250259
"Prepare call hierarchy item at point."
251260
(save-excursion
252-
(gptel-cpp-complete--goto-function-name)
261+
(gptel-cpp-complete--with-which-function-mode
262+
(gptel-cpp-complete--goto-function-name))
253263
(when-let* ((server (eglot--current-server-or-lose))
254264
(pos (eglot--pos-to-lsp-position (point)))
255265
(params `(:textDocument (:uri ,(eglot-path-to-uri

0 commit comments

Comments
 (0)