@@ -242,10 +242,7 @@ Because some variables are buffer local.")
242242(defvar-local lsp-ui-doc--from-mouse nil
243243 " Non nil when the doc was triggered by a mouse event." )
244244(defvar-local lsp-ui-doc--from-mouse-current nil
245- " Non nil when the current call is triggered by a mouse event." )
246- (defvar-local lsp-ui-doc--hide-on-next-command nil
247- " Non-nil when the current document should ask to hide after next command." )
248-
245+ " Non nil when the current call is triggered by a mouse event" )
249246
250247(defconst lsp-ui-doc--buffer-prefix " *lsp-ui-doc-" )
251248
@@ -297,7 +294,8 @@ Because some variables are buffer local.")
297294
298295(defsubst lsp-ui-doc--inline-visible-p ()
299296 " Return inline documentation visibility."
300- (and (overlayp lsp-ui-doc--inline-ov) (overlay-buffer lsp-ui-doc--inline-ov)))
297+ (and (overlayp lsp-ui-doc--inline-ov)
298+ (overlay-buffer lsp-ui-doc--inline-ov)))
301299
302300(defun lsp-ui-doc--inline-wrapped-line (string )
303301 " Wraps a line of text (STRING) for inline display."
@@ -425,20 +423,15 @@ We don't extract the string that `lps-line' is already displaying."
425423 (-when-let* ((xw (lsp-ui-doc--webkit-get-xwidget)))
426424 (xwidget-webkit-execute-script-rv xw script)))
427425
428- (defvar-local lsp-ui-doc--unfocus-frame-timer nil )
429-
430426(defun lsp-ui-doc--hide-frame (&optional _win )
431427 " Hide any documentation frame or overlay."
432428 (setq lsp-ui-doc--bounds nil
433429 lsp-ui-doc--from-mouse nil )
434430 (lsp-ui-util-safe-delete-overlay lsp-ui-doc--inline-ov)
435431 (lsp-ui-util-safe-delete-overlay lsp-ui-doc--highlight-ov)
436- (remove-hook 'post-command-hook 'lsp-ui-doc--hide-frame )
437432 (when-let ((frame (lsp-ui-doc--get-frame)))
438433 (when (frame-visible-p frame)
439- (make-frame-invisible frame)))
440- (setq lsp-ui-doc--unfocus-frame-timer
441- (run-at-time 0 nil #'lsp-ui-doc-unfocus-frame )))
434+ (make-frame-invisible frame))))
442435
443436(defun lsp-ui-doc--buffer-width ()
444437 " Calculate the max width of the buffer."
@@ -829,11 +822,10 @@ HEIGHT is the documentation number of lines."
829822 (-let* ((height (lsp-ui-doc--inline-height))
830823 ((start . end) (lsp-ui-doc--inline-pos height))
831824 (buffer-string (buffer-substring start end))
832- (ov (if (overlayp lsp-ui-doc--inline-ov)
833- (progn
834- (move-overlay lsp-ui-doc--inline-ov start end)
835- lsp-ui-doc--inline-ov)
836- (setq lsp-ui-doc--inline-ov (make-overlay start end)))))
825+ (ov (if (not (overlayp lsp-ui-doc--inline-ov))
826+ (setq lsp-ui-doc--inline-ov (make-overlay start end))
827+ (move-overlay lsp-ui-doc--inline-ov start end)
828+ lsp-ui-doc--inline-ov)))
837829 (overlay-put ov 'face 'default )
838830 (overlay-put ov 'display (lsp-ui-doc--inline-merge buffer-string))
839831 (overlay-put ov 'lsp-ui-doc-inline t )
@@ -932,22 +924,21 @@ HEIGHT is the documentation number of lines."
932924 (lsp--capability " hoverProvider" ))
933925 (-if-let (bounds (or (and (symbol-at-point ) (bounds-of-thing-at-point 'symbol ))
934926 (and (looking-at " [[:graph:]]" ) (cons (point ) (1+ (point ))))))
935- (unless (and ( equal lsp-ui-doc--bounds bounds) ( not lsp-ui-doc--hide-on-next-command) )
927+ (unless (equal lsp-ui-doc--bounds bounds)
936928 (lsp-ui-doc--hide-frame)
937929 (lsp-ui-util-safe-kill-timer lsp-ui-doc--timer)
938930 (setq lsp-ui-doc--timer
939931 (run-with-idle-timer
940932 lsp-ui-doc-delay nil
941- (let ((buf (current-buffer ))
942- (hide lsp-ui-doc--hide-on-next-command))
933+ (let ((buf (current-buffer )))
943934 (lambda nil
944935 (when (equal buf (current-buffer ))
945936 (lsp-request-async
946937 " textDocument/hover"
947938 (lsp--text-document-position-params)
948939 (lambda (hover )
949940 (when (equal buf (current-buffer ))
950- (lsp-ui-doc--callback hover bounds (current-buffer ) hide )))
941+ (lsp-ui-doc--callback hover bounds (current-buffer ))))
951942 :mode 'tick
952943 :cancel-token :lsp-ui-doc-hover )))))))
953944 (lsp-ui-doc--hide-frame))))
@@ -959,21 +950,17 @@ HEIGHT is the documentation number of lines."
959950 (end (-some-> (lsp:range-end data) lsp--position-to-point)))
960951 (cons start end)))
961952
962- (lsp-defun lsp-ui-doc--callback ((hover &as &Hover? :contents ) bounds buffer hide )
953+ (lsp-defun lsp-ui-doc--callback ((hover &as &Hover? :contents ) bounds buffer)
963954 " Process the received documentation.
964955HOVER is the doc returned by the LS.
965956BOUNDS are points of the symbol that have been requested.
966- BUFFER is the buffer where the request has been made.
967- When HIDE is non-nil, hide the doc on next command."
957+ BUFFER is the buffer where the request has been made."
968958 (let ((bounds (or (lsp-ui-doc--extract-bounds hover) bounds)))
969959 (if (and hover
970960 (>= (point ) (car bounds))
971961 (<= (point ) (cdr bounds))
972962 (eq buffer (current-buffer )))
973963 (progn
974- (lsp-ui-util-safe-kill-timer lsp-ui-doc--unfocus-frame-timer)
975- (when hide
976- (add-hook 'post-command-hook 'lsp-ui-doc--hide-frame ))
977964 (setq lsp-ui-doc--bounds bounds)
978965 (lsp-ui-doc--display
979966 (thing-at-point 'symbol t )
@@ -1081,7 +1068,7 @@ Argument WIN is current applying window."
10811068 (goto-char lsp-ui-doc--last-event)
10821069 (let ((lsp-ui-doc-position 'at-point )
10831070 (lsp-ui-doc--from-mouse-current t ))
1084- (lsp-ui-doc--callback hover bounds (current-buffer ) nil ))))
1071+ (lsp-ui-doc--callback hover bounds (current-buffer )))))
10851072 :mode 'tick
10861073 :cancel-token :lsp-ui-doc-hover ))))))
10871074
@@ -1180,11 +1167,23 @@ It is supposed to be called from `lsp-ui--toggle'"
11801167 (interactive )
11811168 (lsp-ui-doc--hide-frame))
11821169
1170+ (defvar-local lsp-ui-doc--unfocus-frame-timer nil )
1171+ (defun lsp-ui-doc--glance-hide-frame ()
1172+ " Hook to hide hover information popup for `lsp-ui-doc-glance' ."
1173+ (when (lsp-ui-doc--visible-p)
1174+ (lsp-ui-doc--hide-frame)
1175+ (remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame )
1176+ ; ; make sure child frame is unfocused
1177+ (setq lsp-ui-doc--unfocus-frame-timer
1178+ (run-at-time 1 nil #'lsp-ui-doc-unfocus-frame ))))
1179+
11831180(defun lsp-ui-doc-glance ()
11841181 " Trigger display hover information popup and hide it on next typing."
11851182 (interactive )
1186- (let ((lsp-ui-doc--hide-on-next-command t ))
1187- (lsp-ui-doc-show)))
1183+ (remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame )
1184+ (lsp-ui-doc-show)
1185+ (lsp-ui-util-safe-kill-timer lsp-ui-doc--unfocus-frame-timer)
1186+ (add-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame ))
11881187
11891188(define-minor-mode lsp-ui-doc-frame-mode
11901189 " Marker mode to add additional key bind for lsp-ui-doc-frame."
0 commit comments