Skip to content

Incorrect/misleading display of descriptions containing exponents #155

Closed

Description

@elirnm

Exponents don't display properly in intellisense, hover, etc, so descriptions that have exponents in them display incorrect/misleading values.

Environment
  • Operating System: Windows 7
  • JDK version: 1.8.0_102
  • Visual Studio Code version: 1.9.1
  • Java extension version: 0.0.10
Steps To Reproduce
  1. Type Integer.MIN_VALUE
  2. Notice that both the autocompletion while typing and the tooltip from hovering over the name say that the minimum value of an int is -231 rather than the -231 present in the Java documentation.

Integer.MAX_VALUE does the same thing on hover (231-1 rather than 231-1) but also adds a slash in the autocompletion dialog (231\-1).

capture

Activity

  1. fbricon commented on Feb 22, 2017

    @fbricon
    Collaborator

    So it seems <sup>31</sup> shouldn't be escaped. I believe this is caused by remark:

     Remark passes the HTML to jsoup, to clean up the input text, which strips unsupported HTML tags (the text will remain)
    

    Remark allows Customization of allowed HTML tags - not really recommended., so I can see how this is going

  2. self-assigned this
    on Feb 22, 2017
  3. added a commit that references this issue on Feb 22, 2017
    ba89865
  4. fbricon commented on Mar 4, 2019

    @fbricon
    Collaborator

    @jrieken @aeschli I tried to return MarkedContent instead of MarkedString, but the sup/sub tags are still not rendered properly. Am I missing something? I thought this would be possible by now.

    [Trace - 3:54:26 PM] Received response 'textDocument/hover - (38)' in 29ms.
    Result: {
        "contents": {
            "kind": "markdown",
            "value": "Content model element which abstracts attribute declaration from a given grammar (XML Schema, DTD). x<sup>x+1</sup>. x<sub>i+1</sub>"
        }
    }
    

    screen shot 2019-03-04 at 4 04 12 pm

  5. jrieken commented on Mar 5, 2019

    @jrieken

    It's markdown, without support for html. You can use unicode variants, like ², or use the 2^32

  6. fbricon commented on Nov 10, 2021

    @fbricon
    Collaborator

    Might be doable now starting with vscode 1.62:

    The new supportHtml property on MarkdownString enables rendering of a safe subset of raw HTML that appears inside the Markdown text.
    The supportHtml property defaults to false. When disabled, VS Code will strip out any raw HTML tags that appear in the Markdown text.

    https://code.visualstudio.com/updates/v1_62?WT.mc_id=devcloud-00000-cxa#_markdownstringsupporthtml

  7. fbricon commented on Dec 3, 2025

    @fbricon
    Collaborator

    New flexmark-java library renders exponents in a slightly better way

    Image
  8. robstryker commented on Oct 28, 2026

    @robstryker
    Contributor

    We're leaving the current behavior in main.

    VS Code's hover doesn't render superscripts, whether the tag is passed through as HTML or written in flexmark's caret syntax, so the converter can only emit plain text. 2^31-1 is the closest to how people write it. Every alternative either keeps an ambiguity, adds parentheses to the common case (2^(31)-1), or looks worse (a closing caret, or Unicode superscripts that don't cover all characters).

    On the specific suggestions: disambiguating x^2y would need parentheses on the token before the sup tag, but the converter streams its output and that text has already been written when the handler runs. Rendering child markup inside a sup tag is for a case that is very rare in javadoc, and it changes how special characters are escaped.

    processSup already parenthesizes exponents that aren't a plain number or word, such as 2^(n+1), which covers the case where the ambiguity matters most. If VS Code adds superscript rendering to hovers, this is the one place to revisit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions