@@ -251,9 +251,6 @@ MODE is the mode used in the parent frame."
251251 (let ((groups (--separate (and (hash-table-p it)
252252 (lsp-get-renderer (gethash " language" it)))
253253 (append list-marked-string nil ))))
254- (when-let ((marked-string (caar groups)))
255- ; ; Without run-with-idle-timer, echo area will be cleared after displaying the message instantly.
256- (run-with-idle-timer 0 nil (lambda () (eldoc-message (lsp-ui-doc--extract-marked-string marked-string)))))
257254 (if lsp-ui-doc-include-signature
258255 list-marked-string
259256 (cadr groups))))
@@ -277,24 +274,6 @@ We don't extract the string that `lps-line' is already displaying."
277274 ((gethash " language" contents) ; ; MarkedString
278275 (lsp-ui-doc--extract-marked-string contents))))
279276
280- (defun lsp-ui-doc--render-on-hover-content (orig-fn contents &rest args )
281- (if lsp-ui-doc-mode
282- contents
283- (apply orig-fn contents args)))
284-
285- (defun lsp-ui-doc--hover-callback (orig-fn from-cache )
286- " Process the received documentation.
287- HOVER is the doc returned by the LS.
288- BOUNDS are points of the symbol that have been requested.
289- BUFFER is the buffer where the request has been made."
290- (if lsp-ui-doc-mode
291- (if lsp--hover-saved-contents
292- (lsp-ui-doc--display (thing-at-point 'symbol t )
293- (lsp-ui-doc--extract lsp--hover-saved-contents))
294- (eldoc-message nil )
295- (lsp-ui-doc--hide-frame))
296- (funcall orig-fn from-cache)))
297-
298277(defun lsp-ui-doc--hide-frame ()
299278 " Hide the frame."
300279 (when (overlayp lsp-ui-doc--inline-ov)
@@ -594,28 +573,37 @@ HEIGHT is the documentation number of lines."
594573 (and (buffer-live-p it) it)
595574 (kill-buffer it)))
596575
576+ (defun lsp-ui-doc--on-hover (_signature-response hover-response )
577+ " Handler for `lsp-on-hover-hook' .
578+ _SIGNATURE-RESPONSE and HOVER-RESPONSE and signature and hover
579+ data that has been loaded for the current position."
580+ (--if-let (-some->> hover-response (gethash " contents" ))
581+ (lsp-ui-doc--display (thing-at-point 'symbol t )
582+ (lsp-ui-doc--extract it))
583+ (eldoc-message nil )
584+ (lsp-ui-doc--hide-frame)))
585+
597586(define-minor-mode lsp-ui-doc-mode
598587 " Minor mode for showing hover information in child frame."
599588 :init-value nil
600589 :group lsp-ui-doc
601590 (cond
602591 (lsp-ui-doc-mode
603- (progn
604- (with-eval-after-load 'frameset
605- ; ; The documentation frame can’t be properly restored. Especially
606- ; ; ‘desktop-save’ will misbehave and save a bogus string "Unprintable
607- ; ; entity" in the desktop file. Therefore we have to prevent
608- ; ; ‘frameset-save’ from saving the parameter.
609- (unless (assq 'lsp-ui-doc-frame frameset-filter-alist)
610- ; ; Copy the variable first. See the documentation of
611- ; ; ‘frameset-filter-alist’ for explanation.
612- (cl-callf copy-tree frameset-filter-alist)
613- (push '(lsp-ui-doc-frame . :never ) frameset-filter-alist)))
614-
615- (advice-add 'lsp--render-on-hover-content :around #'lsp-ui-doc--render-on-hover-content )
616- (advice-add 'lsp--hover-callback :around #'lsp-ui-doc--hover-callback )
617- (add-hook 'delete-frame-functions 'lsp-ui-doc--on-delete nil t )))
592+ (with-eval-after-load 'frameset
593+ ; ; The documentation frame can’t be properly restored. Especially
594+ ; ; ‘desktop-save’ will misbehave and save a bogus string "Unprintable
595+ ; ; entity" in the desktop file. Therefore we have to prevent
596+ ; ; ‘frameset-save’ from saving the parameter.
597+ (unless (assq 'lsp-ui-doc-frame frameset-filter-alist)
598+ ; ; Copy the variable first. See the documentation of
599+ ; ; ‘frameset-filter-alist’ for explanation.
600+ (cl-callf copy-tree frameset-filter-alist)
601+ (push '(lsp-ui-doc-frame . :never ) frameset-filter-alist)))
602+
603+ (add-hook 'lsp-on-hover-hook 'lsp-ui-doc--on-hover nil t )
604+ (add-hook 'delete-frame-functions 'lsp-ui-doc--on-delete nil t ))
618605 (t
606+ (remove-hook 'lsp-on-hover-hook 'lsp-ui-doc--on-hover )
619607 (remove-hook 'delete-frame-functions 'lsp-ui-doc--on-delete t ))))
620608
621609(defun lsp-ui-doc-enable (enable )
0 commit comments