From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- editors/vscode/client/hover.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 editors/vscode/client/hover.js (limited to 'editors/vscode/client/hover.js') diff --git a/editors/vscode/client/hover.js b/editors/vscode/client/hover.js new file mode 100644 index 0000000..24181c5 --- /dev/null +++ b/editors/vscode/client/hover.js @@ -0,0 +1,21 @@ +// Convert protocol hover contents to VS Code MarkdownString objects. +// MarkupContent, legacy MarkedString, and arrays are all valid LSP responses. +function hoverContents(vscode, contents) { + const entries = Array.isArray(contents) ? contents : [contents]; + const result = []; + for (const entry of entries) { + if (!entry) continue; + const value = typeof entry === 'string' ? entry : entry.value; + if (typeof value !== 'string' || !value) continue; + const md = new vscode.MarkdownString(); + if (typeof entry === 'object' && entry.kind === 'plaintext') md.appendText(value); + else if (typeof entry === 'object' && typeof entry.language === 'string') md.appendCodeblock(value, entry.language); + else md.appendMarkdown(value); + md.supportHtml = false; + md.isTrusted = false; + result.push(md); + } + return result; +} + +module.exports = { hoverContents }; -- cgit v1.2.3