@@ -242,10 +242,7 @@ Because some variables are buffer local.")
242
242
(defvar-local lsp-ui-doc--from-mouse nil
243
243
" Non nil when the doc was triggered by a mouse event." )
244
244
(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" )
249
246
250
247
(defconst lsp-ui-doc--buffer-prefix " *lsp-ui-doc-" )
251
248
@@ -297,7 +294,8 @@ Because some variables are buffer local.")
297
294
298
295
(defsubst lsp-ui-doc--inline-visible-p ()
299
296
" 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)))
301
299
302
300
(defun lsp-ui-doc--inline-wrapped-line (string )
303
301
" 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."
425
423
(-when-let* ((xw (lsp-ui-doc--webkit-get-xwidget)))
426
424
(xwidget-webkit-execute-script-rv xw script)))
427
425
428
- (defvar-local lsp-ui-doc--unfocus-frame-timer nil )
429
-
430
426
(defun lsp-ui-doc--hide-frame (&optional _win )
431
427
" Hide any documentation frame or overlay."
432
428
(setq lsp-ui-doc--bounds nil
433
429
lsp-ui-doc--from-mouse nil )
434
430
(lsp-ui-util-safe-delete-overlay lsp-ui-doc--inline-ov)
435
431
(lsp-ui-util-safe-delete-overlay lsp-ui-doc--highlight-ov)
436
- (remove-hook 'post-command-hook 'lsp-ui-doc--hide-frame )
437
432
(when-let ((frame (lsp-ui-doc--get-frame)))
438
433
(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))))
442
435
443
436
(defun lsp-ui-doc--buffer-width ()
444
437
" Calculate the max width of the buffer."
@@ -829,11 +822,10 @@ HEIGHT is the documentation number of lines."
829
822
(-let* ((height (lsp-ui-doc--inline-height))
830
823
((start . end) (lsp-ui-doc--inline-pos height))
831
824
(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)))
837
829
(overlay-put ov 'face 'default )
838
830
(overlay-put ov 'display (lsp-ui-doc--inline-merge buffer-string))
839
831
(overlay-put ov 'lsp-ui-doc-inline t )
@@ -932,22 +924,21 @@ HEIGHT is the documentation number of lines."
932
924
(lsp--capability " hoverProvider" ))
933
925
(-if-let (bounds (or (and (symbol-at-point ) (bounds-of-thing-at-point 'symbol ))
934
926
(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)
936
928
(lsp-ui-doc--hide-frame)
937
929
(lsp-ui-util-safe-kill-timer lsp-ui-doc--timer)
938
930
(setq lsp-ui-doc--timer
939
931
(run-with-idle-timer
940
932
lsp-ui-doc-delay nil
941
- (let ((buf (current-buffer ))
942
- (hide lsp-ui-doc--hide-on-next-command))
933
+ (let ((buf (current-buffer )))
943
934
(lambda nil
944
935
(when (equal buf (current-buffer ))
945
936
(lsp-request-async
946
937
" textDocument/hover"
947
938
(lsp--text-document-position-params)
948
939
(lambda (hover )
949
940
(when (equal buf (current-buffer ))
950
- (lsp-ui-doc--callback hover bounds (current-buffer ) hide )))
941
+ (lsp-ui-doc--callback hover bounds (current-buffer ))))
951
942
:mode 'tick
952
943
:cancel-token :lsp-ui-doc-hover )))))))
953
944
(lsp-ui-doc--hide-frame))))
@@ -959,21 +950,17 @@ HEIGHT is the documentation number of lines."
959
950
(end (-some-> (lsp:range-end data) lsp--position-to-point)))
960
951
(cons start end)))
961
952
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)
963
954
" Process the received documentation.
964
955
HOVER is the doc returned by the LS.
965
956
BOUNDS 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."
968
958
(let ((bounds (or (lsp-ui-doc--extract-bounds hover) bounds)))
969
959
(if (and hover
970
960
(>= (point ) (car bounds))
971
961
(<= (point ) (cdr bounds))
972
962
(eq buffer (current-buffer )))
973
963
(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 ))
977
964
(setq lsp-ui-doc--bounds bounds)
978
965
(lsp-ui-doc--display
979
966
(thing-at-point 'symbol t )
@@ -1024,7 +1011,8 @@ before, or if the new window is the minibuffer."
1024
1011
(or (not (eq (selected-window ) (frame-parameter frame 'lsp-ui-doc--window-origin )))
1025
1012
(not (eq (window-buffer ) (frame-parameter frame 'lsp-ui-doc--buffer-origin ))))
1026
1013
(if on-idle (lsp-ui-doc--hide-frame)
1027
- (lsp-ui-util-safe-kill-timer lsp-ui-doc--timer-on-changes)
1014
+ (and (timerp lsp-ui-doc--timer-on-changes)
1015
+ (cancel-timer lsp-ui-doc--timer-on-changes))
1028
1016
(setq lsp-ui-doc--timer-on-changes
1029
1017
(run-with-idle-timer 0 nil (lambda nil (lsp-ui-doc--on-state-changed frame t ))))))))
1030
1018
@@ -1081,7 +1069,7 @@ Argument WIN is current applying window."
1081
1069
(goto-char lsp-ui-doc--last-event)
1082
1070
(let ((lsp-ui-doc-position 'at-point )
1083
1071
(lsp-ui-doc--from-mouse-current t ))
1084
- (lsp-ui-doc--callback hover bounds (current-buffer ) nil ))))
1072
+ (lsp-ui-doc--callback hover bounds (current-buffer )))))
1085
1073
:mode 'tick
1086
1074
:cancel-token :lsp-ui-doc-hover ))))))
1087
1075
@@ -1180,11 +1168,23 @@ It is supposed to be called from `lsp-ui--toggle'"
1180
1168
(interactive )
1181
1169
(lsp-ui-doc--hide-frame))
1182
1170
1171
+ (defvar-local lsp-ui-doc--unfocus-frame-timer nil )
1172
+ (defun lsp-ui-doc--glance-hide-frame ()
1173
+ " Hook to hide hover information popup for `lsp-ui-doc-glance' ."
1174
+ (when (lsp-ui-doc--visible-p)
1175
+ (lsp-ui-doc--hide-frame)
1176
+ (remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame )
1177
+ ; ; make sure child frame is unfocused
1178
+ (setq lsp-ui-doc--unfocus-frame-timer
1179
+ (run-at-time 1 nil #'lsp-ui-doc-unfocus-frame ))))
1180
+
1183
1181
(defun lsp-ui-doc-glance ()
1184
1182
" Trigger display hover information popup and hide it on next typing."
1185
1183
(interactive )
1186
- (let ((lsp-ui-doc--hide-on-next-command t ))
1187
- (lsp-ui-doc-show)))
1184
+ (remove-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame )
1185
+ (lsp-ui-doc-show)
1186
+ (lsp-ui-util-safe-kill-timer lsp-ui-doc--unfocus-frame-timer)
1187
+ (add-hook 'post-command-hook 'lsp-ui-doc--glance-hide-frame ))
1188
1188
1189
1189
(define-minor-mode lsp-ui-doc-frame-mode
1190
1190
" Marker mode to add additional key bind for lsp-ui-doc-frame."
0 commit comments