Skip to content

Commit c2df88f

Browse files
committed
dap-mouse: refactor: drop `dap--tooltip-request'
That variable served no useful purpose. Remove it, simplifying the code and removing a liability: it would grow forever (incremented).
1 parent 9db997c commit c2df88f

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

dap-mouse.el

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ If there is an active selection - return it."
133133
(bounds-of-thing-at-point 'symbol))))
134134

135135
(defvar-local dap-tooltip-bounds nil)
136-
(defvar-local dap-tooltip--request 0)
137-
138136
(defun dap-tooltip-post-tooltip ()
139137
"Clean tooltip properties."
140138

@@ -175,10 +173,8 @@ The result is displayed in a `treemacs' `posframe'. POS,
175173
defaulting to `point', specifies where the cursor is and
176174
consequently where to show the `posframe'."
177175
(interactive)
178-
(cl-incf dap-tooltip--request)
179176
(let ((debug-session (dap--cur-session))
180-
(mouse-point (or pos (point)))
181-
(request-id dap-tooltip--request))
177+
(mouse-point (or pos (point))))
182178
(when (and (dap--session-running debug-session)
183179
mouse-point)
184180
(-when-let* ((active-frame-id (-some->> debug-session
@@ -196,21 +192,20 @@ consequently where to show the `posframe'."
196192
(dap--resp-handler
197193
(-lambda ((&hash "body" (&hash? "result"
198194
"variablesReference" variables-reference)))
199-
(when (= request-id dap-tooltip--request)
200-
(add-text-properties
201-
start end '(mouse-face dap-mouse-eval-thing-face))
202-
;; Show a dead buffer so that the `posframe' size is consistent.
203-
(when (get-buffer dap-mouse-buffer)
204-
(kill-buffer dap-mouse-buffer))
205-
(unless (and (zerop variables-reference) (string-empty-p result))
206-
(apply #'posframe-show dap-mouse-buffer
207-
:position start
208-
:accept-focus t
209-
dap-mouse-posframe-properties)
210-
(with-current-buffer (get-buffer-create dap-mouse-buffer)
211-
(dap-ui-render-value debug-session expression
212-
result variables-reference)))
213-
(add-hook 'post-command-hook 'dap-tooltip-post-tooltip)))
195+
(add-text-properties
196+
start end '(mouse-face dap-mouse-eval-thing-face))
197+
;; Show a dead buffer so that the `posframe' size is consistent.
198+
(when (get-buffer dap-mouse-buffer)
199+
(kill-buffer dap-mouse-buffer))
200+
(unless (and (zerop variables-reference) (string-empty-p result))
201+
(apply #'posframe-show dap-mouse-buffer
202+
:position start
203+
:accept-focus t
204+
dap-mouse-posframe-properties)
205+
(with-current-buffer (get-buffer-create dap-mouse-buffer)
206+
(dap-ui-render-value debug-session expression
207+
result variables-reference)))
208+
(add-hook 'post-command-hook 'dap-tooltip-post-tooltip))
214209
;; TODO: hover failure will yield weird errors involving process
215210
;; filters, so I resorted to this hack; we should proably do proper
216211
;; error handling, with a whitelist of allowable errors.

0 commit comments

Comments
 (0)