Skip to content

[Bug]: Rendering of string, MarkedString and MarkedContent #1303

Description

@brownts

Environment

  • OS and Version: Ubuntu 24.04
  • IDE Version: Emacs 29/30/31
  • Ada & SPARK Extension Version: 2026.2.202604091

Bug Summary and Reproducer

I've had a couple different issues where "string" or "MarkedString" are not rendered as expected by the LSP client.

One example was documented in Emacs Bug#74807, where I argued that the Emacs built-in LSP client (i.e., Eglot) should not be treating a documentation "string", in a CompletionItem response, as Markdown. In that particular example, the documentation string was for the GNAT Project Format'End_Of_Line attribute (i.e., "End of line sequence: lf | crlf"). That documentation response was being rendered as Markdown, and the colon (:) was being interpreted as a markdown definition list and rendered as such. My expectation is that the colon was not intended to cause specific rendering and instead was expected to be rendered as plain text instead. I was unsuccessful in convincing the Eglot author to change their implementation. Would it be possible for the Ada Language Server to use MarkdownContent with a plaintext kind for CompletionItem documentation instead of string? I believe doing so would address this discrepency.

Another scenario involves a MarkedString used for textDocument/hover responses. It seems when attempting to render plain text, the language field specified in the MarkedString by the Ada Language Server is plaintext. It seems not all markdown renderers understand the meaning of the plaintext language, and may render the text as Markdown instead of plain text. Looking at the documentation in the LSP specification for MarkedString, "... the language identifier is semantically equal to the optional language identifier in fenced code blocks in GitHub issues." I went looking for the set of valid languages for GitHub Markdown code blocks. The GitHub documentation, pointed at Linguist, which seems to contain the valid set of languages (and aliases) in langauges.yml. I could not find plaintext listed there. I could only find plain text as an alias for text. Would it be possible to specify text instead of plaintext in MarkedString? This would address the issue where not all markdown renderers properly handled the plaintext language.

I had noticed too that MarkedString was marked deprecated in the LSP specification, and it seems that MarkedContent has been around for quite a while at this point. Maybe it makes sense to move everything to MarkedContent at this point?

Configuration and Logs

[ALS.IN] {"jsonrpc":"2.0","id":9,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/troy/junk/crate/gtkada_24.0.0_80c56171/src/generated/glib-variant.ads"},"position":{"line":235,"character":12}}} (18:17:38.880)
[ALS.IN] {"jsonrpc":"2.0","id":10,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///home/troy/junk/crate/gtkada_24.0.0_80c56171/src/generated/glib-variant.ads"},"position":{"line":235,"character":12}}} (18:17:38.880)
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-303660-indexing-1","value":{"kind":"report","message":"2072/2236 files","percentage":92}}} (18:17:38.901)
[ALS.OUT] {"jsonrpc":"2.0","id":9,"result":{"contents":[{"language":"ada","value":"package GNAT.Strings renames System.Strings;"},"at g-string.ads (38:1)",{"language":"plaintext","value":"See file s-string.ads for full documentation of the interface"}]}} (18:17:38.902)

Other VS Code Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions