Skip to content

Commit ce997c4

Browse files
authored
Fix checks on markup-content (#461)
1 parent a229185 commit ce997c4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lsp-ui-doc.el

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,24 @@ CONTENTS can be differents type of values:
289289
MarkedString | MarkedString[] | MarkupContent (as defined in the LSP).
290290
We don't extract the string that `lps-line' is already displaying."
291291
(cond
292-
((stringp contents) (lsp-ui-doc--extract-marked-string contents)) ;; MarkedString
293292
((vectorp contents) ;; MarkedString[]
294293
(mapconcat 'lsp-ui-doc--extract-marked-string
295294
(lsp-ui-doc--filter-marked-string (seq-filter #'identity contents))
296295
"\n\n"
297296
;; (propertize "\n\n" 'face '(:height 0.4))
298297
))
299298
;; when we get markdown contents, render using emacs gfm-view-mode / markdown-mode
300-
((string= (lsp-markup-content? contents) lsp/markup-kind-markdown) ;; Markdown MarkupContent
301-
(lsp-ui-doc--extract-marked-string (lsp:markup-content-value contents) lsp/markup-kind-markdown))
302-
((lsp-markup-content? contents) (lsp:markup-content-value contents)) ;; Plaintext MarkupContent
303-
((lsp-marked-string? contents) ;; MarkedString
299+
((and (lsp-marked-string? contents)
300+
(lsp:marked-string-language contents))
304301
(lsp-ui-doc--extract-marked-string (lsp:marked-string-value contents)
305-
(lsp:marked-string-language contents)))))
302+
(lsp:marked-string-language contents)))
303+
((lsp-marked-string? contents) (lsp-ui-doc--extract-marked-string contents))
304+
((and (lsp-markup-content? contents)
305+
(string= (lsp:markup-content-kind contents) lsp/markup-kind-markdown))
306+
(lsp-ui-doc--extract-marked-string (lsp:markup-content-value contents) lsp/markup-kind-markdown))
307+
((and (lsp-markup-content? contents)
308+
(string= (lsp:markup-content-kind contents) lsp/markup-kind-plain-text))
309+
(lsp:markup-content-value contents))))
306310

307311
(defun lsp-ui-doc--webkit-run-xwidget ()
308312
"Launch embedded WebKit instance."

lsp-ui-sideline.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ We prioritize string with a language (which is probably a type or a
221221
function signature)."
222222
(when contents
223223
(cond
224-
((stringp contents) contents)
225-
((vectorp contents) ;; MarkedString[]
224+
((lsp-marked-string? contents) contents)
225+
((vectorp contents)
226226
(seq-find (lambda (it) (and (lsp-marked-string? it)
227227
(lsp-get-renderer (lsp:marked-string-language it))))
228228
contents))
229-
((lsp-markup-content? contents) contents) ;; MarkupContent
230-
((lsp-marked-string? contents) contents))))
229+
((lsp-markup-content? contents) contents))))
230+
231231

232232
(defun lsp-ui-sideline--format-info (marked-string)
233233
"Format MARKED-STRING.

0 commit comments

Comments
 (0)