3737(require 'markdown-mode )
3838(require 'cl-lib )
3939(require 'lsp-ui-util )
40+ (require 'subr-x )
4041
4142(when (featurep 'xwidget-internal )
4243 (require 'xwidget ))
@@ -389,15 +390,12 @@ We don't extract the string that `lps-line' is already displaying."
389390 " Hide the frame."
390391 (setq lsp-ui-doc--bounds nil
391392 lsp-ui-doc--from-mouse nil )
392- (when (overlayp lsp-ui-doc--inline-ov)
393- (delete-overlay lsp-ui-doc--inline-ov))
394- (when (overlayp lsp-ui-doc--highlight-ov)
395- (delete-overlay lsp-ui-doc--highlight-ov))
396- (when (lsp-ui-doc--get-frame)
393+ (lsp-ui-util-safe-delete-overlay lsp-ui-doc--inline-ov)
394+ (lsp-ui-util-safe-delete-overlay lsp-ui-doc--highlight-ov)
395+ (when-let ((frame (lsp-ui-doc--get-frame)))
397396 (unless lsp-ui-doc-use-webkit
398- (lsp-ui-doc--with-buffer
399- (erase-buffer )))
400- (make-frame-invisible (lsp-ui-doc--get-frame))))
397+ (lsp-ui-doc--with-buffer (erase-buffer )))
398+ (make-frame-invisible frame)))
401399
402400(defun lsp-ui-doc--buffer-width ()
403401 " Calcul the max width of the buffer."
@@ -870,7 +868,7 @@ HEIGHT is the documentation number of lines."
870868 (and (looking-at " [[:graph:]]" ) (cons (point ) (1+ (point ))))))
871869 (unless (equal lsp-ui-doc--bounds bounds)
872870 (lsp-ui-doc--hide-frame)
873- (and lsp-ui-doc--timer ( cancel -timer lsp-ui-doc--timer) )
871+ (lsp-ui-util-safe-kill -timer lsp-ui-doc--timer)
874872 (setq lsp-ui-doc--timer
875873 (run-with-idle-timer
876874 lsp-ui-doc-delay nil
@@ -887,19 +885,6 @@ HEIGHT is the documentation number of lines."
887885 :cancel-token :lsp-ui-doc-hover )))))))
888886 (lsp-ui-doc--hide-frame))))
889887
890- (defcustom lsp-ui-doc-post-delay 0.2
891- " Seconds to wait before making post request."
892- :type 'number
893- :group 'lsp-ui-doc )
894-
895- (defvar-local lsp-ui-doc--post-timer nil
896- " Timer for post command." )
897-
898- (defun lsp-ui-doc--post-command ()
899- " Post command hook for UI doc."
900- (lsp-ui-util-safe-kill-timer lsp-ui-doc--post-timer)
901- (setq lsp-ui-doc--post-timer (run-with-timer lsp-ui-doc-post-delay nil #'lsp-ui-doc--make-request )))
902-
903888(defun lsp-ui-doc--extract-bounds (hover )
904889 (-when-let* ((hover hover)
905890 (data (lsp-get hover :range ))
@@ -1099,15 +1084,15 @@ If nil, do not prevent mouse on prefix keys.")
10991084 (add-hook 'window-state-change-functions 'lsp-ui-doc--on-state-changed ))
11001085 (lsp-ui-doc--setup-mouse)
11011086 (advice-add 'handle-switch-frame :before-while 'lsp-ui-doc--prevent-focus-doc )
1102- (add-hook 'post-command-hook 'lsp-ui-doc--post-command nil t )
1087+ (add-hook 'post-command-hook 'lsp-ui-doc--make-request nil t )
11031088 (add-hook 'window-scroll-functions 'lsp-ui-doc--handle-scroll nil t )
11041089 (add-hook 'delete-frame-functions 'lsp-ui-doc--on-delete nil t ))
11051090 (t
11061091 (lsp-ui-doc-hide)
11071092 (when (boundp 'window-state-change-functions )
11081093 (remove-hook 'window-state-change-functions 'lsp-ui-doc--on-state-changed ))
11091094 (remove-hook 'window-scroll-functions 'lsp-ui-doc--handle-scroll t )
1110- (remove-hook 'post-command-hook 'lsp-ui-doc--post-command t )
1095+ (remove-hook 'post-command-hook 'lsp-ui-doc--make-request t )
11111096 (remove-hook 'delete-frame-functions 'lsp-ui-doc--on-delete t ))))
11121097
11131098(defun lsp-ui-doc-enable (enable )
0 commit comments