Skip to content

Commit deb08ed

Browse files
committed
Fix lsp-ui-doc-glance auto-hide
Fixes #695 For some inexplicable reason, `lsp-ui-doc-show` calls `lsp-ui-doc--callback` synchronously, while `lsp-ui-doc-glance` went via a more tortuous asynchronous route (via `lsp-ui-doc--make-request`). This commit makes `lsp-ui-doc-glance` equivalent to calling `lsp-ui-doc-show` followed by *delayed* addition to `post-command-hook` (since we're already in a command) of the `lsp-ui-doc--glance-hide-frame` function. Note that `lsp-ui-doc--glance-hide-frame` is also simplified to just remove itself from `post-command-hook` and directly call `lsp-ui-doc-hide`.
1 parent 370022b commit deb08ed

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

lsp-ui-doc.el

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,25 +1164,18 @@ It is supposed to be called from `lsp-ui--toggle'"
11641164
(interactive)
11651165
(lsp-ui-doc--hide-frame))
11661166

1167-
(defvar-local lsp-ui-doc--unfocus-frame-timer nil)
11681167
(defun lsp-ui-doc--glance-hide-frame ()
1169-
"Hook to hide hover information popup for `lsp-ui-doc-glance'."
1170-
(when (or (overlayp lsp-ui-doc--inline-ov)
1171-
(lsp-ui-doc--frame-visible-p))
1172-
(lsp-ui-doc--hide-frame)
1173-
(remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame)
1174-
;; make sure child frame is unfocused
1175-
(setq lsp-ui-doc--unfocus-frame-timer
1176-
(run-at-time 1 nil #'lsp-ui-doc-unfocus-frame))))
1168+
"Hook function for auto-hiding hover information popup for `lsp-ui-doc-glance'."
1169+
(remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame)
1170+
(lsp-ui-doc--hide-frame))
11771171

11781172
(defun lsp-ui-doc-glance ()
11791173
"Trigger display hover information popup and hide it on next typing."
11801174
(interactive)
1181-
(let ((lsp-ui-doc-show-with-cursor t))
1182-
(lsp-ui-doc--make-request))
1183-
(when lsp-ui-doc--unfocus-frame-timer
1184-
(cancel-timer lsp-ui-doc--unfocus-frame-timer))
1185-
(add-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame))
1175+
(lsp-ui-doc-show)
1176+
(run-at-time 1 nil
1177+
(lambda ()
1178+
(add-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame))))
11861179

11871180
(define-minor-mode lsp-ui-doc-frame-mode
11881181
"Marker mode to add additional key bind for lsp-ui-doc-frame."

0 commit comments

Comments
 (0)