diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /editors/vscode/client/hover.js | |
a
Diffstat (limited to 'editors/vscode/client/hover.js')
| -rw-r--r-- | editors/vscode/client/hover.js | 21 |
1 files changed, 21 insertions, 0 deletions
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 }; |
