branch: externals/dape
commit efcfc93003177bf963c8ec75d65d03e7d0254552
Author: Daniel Pettersson <[email protected]>
Commit: Daniel Pettersson <[email protected]>

    Fix duplicate variable overlays
    
    As for all of the variable lookup code, this is a bit hacky as it
    relies upon locals being the first scope.
---
 dape.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/dape.el b/dape.el
index 7e93a385b3..15ef762e3d 100644
--- a/dape.el
+++ b/dape.el
@@ -1613,9 +1613,19 @@ Search is bounded to BEG and END."
 
 (defun dape--variable-add-overlay (variable marker)
   "Add inline variable overlay for VARIABLE at MARKER."
-  (when-let ((buffer (marker-buffer marker)))
+  (when-let ((buffer (marker-buffer marker))
+             (beg (1- (marker-position marker)))
+             (end (marker-position marker)))
     (with-current-buffer buffer
-      (when-let* ((ov (make-overlay (1- (marker-position marker)) marker))
+      (when-let* ((ov (make-overlay beg end))
+                  ;; Skip adding overlay, all ready placed this is most often
+                  ;; the correct way due to locals being the first scope for
+                  ;; most adapters
+                  ((not (cl-member 'dape-variable-overlay
+                                   (overlays-at beg)
+                                   :key
+                                   (lambda (ov)
+                                     (overlay-get ov 'category)))))
                   (var-string (plist-get variable :value))
                   (max-length (or (string-match-p "\n" var-string)
                                   dape-inline-variable-length))
@@ -1624,6 +1634,8 @@ Search is bounded to BEG and END."
                                        (propertize "..." 'face 'shadow)))))
         (overlay-put ov 'after-string
                      (format " %s " (propertize ov-string 'face 'shadow)))
+        (overlay-put ov 'help-echo ov-string)
+        (overlay-put ov 'category 'dape-variable-overlay)
         (overlay-put ov 'evaporate t)
         (push ov dape--variable-overlays)))))
 

Reply via email to