yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Hover is always converting the contents to markdown

Open jpinkney-aws opened this issue 2 years ago • 3 comments

Describe the bug

When you hover over a element that has a schema applied the hover results get converted directly into markdown regardless of whether or not you are using the description json schema field or the markdownDescription json schema field. This actually breaks non-VSCode editors like Visual Studio, which can't/don't handle the markdown from hover gracefully.

It's also worth noting that we don't convert our completion description results to markdown. They are shown as plaintext.

Expected Behavior

Hovers coming from description json schema fields should not re-render everything as markdown. We should only convert the incoming description as markdown when the user uses the markdownDescription field in the schema.

Current Behavior

Every hover request gets rendered as markdown.

Related code: https://github.com/redhat-developer/yaml-language-server/blob/main/src/languageservice/services/yamlHover.ts#L89 and https://github.com/redhat-developer/yaml-language-server/blob/main/src/languageservice/services/yamlHover.ts#L117

Steps to Reproduce

  1. Create file with schema attached that has a description that should be rendered as plaintext
  2. Hover over an element
  3. Observe that the hover element gets converted to markdown

Environment

  • [ ] Windows
  • [X] Mac
  • [ ] Linux
  • [ ] other (please specify)

jpinkney-aws avatar Jan 24 '23 16:01 jpinkney-aws

Are you planning to send a PR for this ?

gorkem avatar Jan 31 '23 15:01 gorkem

Looks like at https://github.com/redhat-developer/yaml-language-server/blob/f8885262ad219e28121d4571bd6fc2a07fec984c/src/languageservice/services/yamlHover.ts#L120 , https://github.com/redhat-developer/yaml-language-server/blob/f8885262ad219e28121d4571bd6fc2a07fec984c/src/languageservice/services/yamlHover.ts#L141

which just treat the regular description as markdown. Seems like it shouldn't be that tricky to handle these cases. We already uses MarkupContent in the hover, which supports both.

Update: Another thing to consider is if we're always returning markdown content, then we're probably not respecting contentFormat

rgrunber avatar Mar 01 '23 16:03 rgrunber