From cbddf468e36aaa335d6c3da6b4da055b1afc3c18 Mon Sep 17 00:00:00 2001 From: Hajime-san <41257923+Hajime-san@users.noreply.github.com> Date: Thu, 23 May 2024 04:00:14 +0900 Subject: fix(lsp): process Fenced Code Block in JSDoc on `completion` correctly (#23822) partially fixing https://github.com/denoland/deno/issues/23820 https://github.com/denoland/deno/assets/41257923/0adb5d4e-cfd5-4195-9045-19d1c0a07a43 BTW, it is out of scope on this PR that to process type of `@param` to be an code block due to it's a bit complicated. --- cli/lsp/tsc.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 97fdb9cb6..5d5f5228c 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -3283,14 +3283,17 @@ impl CompletionEntryDetails { None }; let documentation = if let Some(parts) = &self.documentation { + // NOTE: similar as `QuickInfo::to_hover()` let mut value = display_parts_to_string(parts, language_server); if let Some(tags) = &self.tags { - let tag_documentation = tags + let tags_preview = tags .iter() .map(|tag_info| get_tag_documentation(tag_info, language_server)) .collect::>() - .join(""); - value = format!("{value}\n\n{tag_documentation}"); + .join(" \n\n"); + if !tags_preview.is_empty() { + value = format!("{value}\n\n{tags_preview}"); + } } Some(lsp::Documentation::MarkupContent(lsp::MarkupContent { kind: lsp::MarkupKind::Markdown, -- cgit v1.2.3