Support MarkupContent[] in a Hover#417
Conversation
|
@DJMcNab can you elaborate why this is necessary. The reason why I am asking is that this is a breaking change for a client and we need to provide capabilities for this. If the reason for this is the rendering in the VS Code UI (horizontal lines) I think we are better off treating |
|
Certainly - the reason is for that UI effect. I created this PR mostly because you labelled #374 as 'feature-request', without raising this issue, which then seemed dormant and unactioned. I also encountered this limitation in a language server I am developing, where I had to fall back on the old deprecated API, which seemed wrong. However, seeing @felixfbecker's solution as laid out in microsoft/language-server-protocol#518 (comment) makes me realise that splitting on the However, the usual visual style of the |
|
@DJMcNab I think the styling of |
|
So, just to clarify, I should close microsoft/language-server-protocol#572 and instead make the change in https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/protocolConverter.ts#L257. What would be the best approach to this - should I force push an update? Is it worth the slight jankiness of splitting based on the raw string |
|
There, I have added the suggested changes. Note that Sourcegraph uses css rules to make the markdown content with horizontal seperators look the same as multiple array items: see sourcegraph/codeintellify@2ab2bf6. @felixfbecker, do you think we should use this approach in vscode, although (I think) that would require a PR against Microsoft/vscode. |
| case ls.MarkupKind.Markdown: | ||
| return new code.MarkdownString(value.value); | ||
| // https://github.com/Microsoft/vscode-languageserver-node/issues/374 | ||
| return value.value.split(/\s*---\s*/g).map(asMarkdownString); |
There was a problem hiding this comment.
Is this correct? What if --- appears in a code snippet, or in the middle of a sentence?
There was a problem hiding this comment.
I am currently fixing it :-) We need to consider *** and ___ as well and ignore html comments
|
@DJMcNab I reverted the merge. The think is more complicated than looking for
Are you willing to continue on this? |
|
Actually this is getting too complicated. We would need to handle |
|
OK! Well I'm glad we're thinking about a solution! Don't worry about it. |
|
Fixed via: microsoft/vscode#65094 The following code: produces the following hover: |
|
Nice, that's the solution we chose in Sourcegraph too 👍 |
|
Awesome work! Thanks. Should we have a note about this in the protocol document - I suppose microsoft/language-server-protocol#518 should track that? Also, does tsserver currently use this or does it use the deprecated |
|
TSServer does use the deprecated I also updated microsoft/language-server-protocol#518 @DJMcNab what do you suggest to add to the protocol document ? |
|
Something like:
Maybe in slightly better English 😃. |
|
I think this is not a good idea since the LSP purposely stayed away from defining how something should be rendered. If there is an editor that renders |
|
Yeah, that's fine. It might be worth noting that |

Fixes #374 and microsoft/language-server-protocol#518.
Supported by microsoft/language-server-protocol#572
Note that
StringOrContentis used to ease type-checking, as TS doesn't seem to be able to implicitely convertls.MarkedString[] | ls.MarkupContent[]to(ls.MarkedString | ls.MarkupContent)[]forArray#map. This does change the semantic meaning ofasHoverContent, but it's an internal function anyway, so ¯\_(ツ)_/¯.