branch: externals/consult
commit 9c79441fb8ec6d837bf6f3fa1124aa7c2f980669
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Improve consult-imenu--normalize (Fix #1255)
---
 consult-imenu.el | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/consult-imenu.el b/consult-imenu.el
index 0af9863813..6b632f8b14 100644
--- a/consult-imenu.el
+++ b/consult-imenu.el
@@ -64,19 +64,15 @@ ARGS are the arguments to the special item function."
 (defun consult-imenu--normalize (pos)
   "Return normalized imenu POS."
   (pcase pos
-    ;; Create marker from integer item
-    ((pred integerp) (setq pos (copy-marker pos)))
-    ;; Semantic uses overlay for positions
-    ((pred overlayp) (setq pos (copy-marker (overlay-start pos))))
-    ;; Wrap special item
+    ;; Wrap special position
     (`(,pos ,fn . ,args)
-     (setq pos `(,pos ,#'consult-imenu--switch-buffer ,(current-buffer)
-                      ,fn ,@args))))
-  (if (or (consp pos)
-          (eq imenu-default-goto-function #'imenu-default-goto-function))
-      pos
-    (list pos #'consult-imenu--switch-buffer (current-buffer)
-          imenu-default-goto-function)))
+     `(,pos ,#'consult-imenu--switch-buffer ,(current-buffer) ,fn ,@args))
+    (_ (if (eq imenu-default-goto-function #'imenu-default-goto-function)
+           ;; Use markers instead of integers, such that positions are 
preserved
+           ;; when editing, and to support jumps across buffers.
+           (if (integerp pos) (copy-marker pos) pos)
+         (list pos #'consult-imenu--switch-buffer (current-buffer)
+               imenu-default-goto-function)))))
 
 (defun consult-imenu--flatten (prefix face list types)
   "Flatten imenu LIST.

Reply via email to