Skip to content

Commit 3107fb2

Browse files
committed
[hover] Display the last MarkedString when there are multiple.
1 parent b8f44e7 commit 3107fb2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lsp-methods.el

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,16 +1229,18 @@ type MarkedString = string | { language: string; value: string };"
12291229
(lsp--point-is-within-bounds-p start end)
12301230
(eq (current-buffer) buffer) (eldoc-display-message-p))
12311231
(let ((contents (gethash "contents" hover)))
1232-
(eldoc-message
1233-
(mapconcat (lambda (e)
1234-
(let (renderer)
1235-
(if (hash-table-p e)
1236-
(if (setq renderer (cdr (assoc-string
1237-
(gethash "language" e) renderers)))
1238-
(funcall renderer (gethash "value" e))
1239-
(gethash "value" e))
1240-
e)))
1241-
(if (listp contents) contents (list contents)) "\n"))))))
1232+
;; We may receive multiple MarkedString's in the Hover response,
1233+
;; render the last one because others are likely comments which will
1234+
;; make the eldoc message span multiple lines.
1235+
(when-let* ((e (if (consp contents) (car (last contents)) contents)))
1236+
(let (renderer)
1237+
(eldoc-message
1238+
(if (hash-table-p e)
1239+
(if (setq renderer (cdr (assoc-string
1240+
(gethash "language" e) renderers)))
1241+
(funcall renderer (gethash "value" e))
1242+
(gethash "value" e))
1243+
e))))))))
12421244

12431245
(defun lsp-provide-marked-string-renderer (client language renderer)
12441246
(cl-check-type language string)

0 commit comments

Comments
 (0)