Skip to content

Plaintext textDocument/hover malformed #10028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sclu1034 opened this issue Aug 25, 2021 · 1 comment · Fixed by #13988
Closed

Plaintext textDocument/hover malformed #10028

sclu1034 opened this issue Aug 25, 2021 · 1 comment · Fixed by #13988
Labels
A-hover hover feature C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@sclu1034
Copy link
Contributor

sclu1034 commented Aug 25, 2021

When an LSP client only reports MarkupKind::Plaintext for capabilities.textDocument.hover.content_format, the text returned for a textDocument/hover request is still advertised as "kind": "markdown" and while the Markdown syntax is removed, whitespace is partially broken.

The following example includes

  • whitespace after dot missing
  • forced newline mid-sentence
  • code blocks not separated from text
{
    "jsonrpc": "2.0",
    "id": 13,
    "result": {
        "contents": {
            "kind": "markdown",
            "value": "fn\n\n\nA function or function pointer.Functions are the primary way code is executed within Rust. Function blocks, usually just\ncalled functions, can be defined in a variety of different places and be assigned many\ndifferent attributes and modifiers.Standalone functions that just sit within a module not attached to anything else are common,\nbut most functions will end up being inside impl blocks, either on another type itself, or\nas a trait impl for that type.fn standalone_function() {\n    // code\n}\n\npub fn public_thing(argument: bool) -> String {\n    // code\n    # \"\".to_string()\n}\n\nstruct Thing {\n    foo: i32,\n}\n\nimpl Thing {\n    pub fn new() -> Self {\n        Self {\n       foo: 42,\n        }\n    }\n}\n\nIn addition to presenting fixed types in the form of fn name(arg: type, ..) -> return_type,\nfunctions can also declare a list of type parameters along with trait bounds that they fall\ninto.fn generic_function<T: Clone>(x: T) -> (T, T, T) {\n    (x.clone(), x.clone(), x.clone())\n}\n\nfn generic_where<T>(x: T) -> T\n    where T: std::ops::Add<Output = T> + Copy\n{\n    x + x + x\n}\n\nDeclaring trait bounds in the angle brackets is functionally identical to using a where\nclause. It's up to the programmer to decide which works better in each situation, but where\ntends to be better when things get longer than one line.Along with being made public via pub, fn can also have an extern added for use in\nFFI.For more information on the various types of functions and how they're used, consult the Rust\nbook or the Reference."
        },
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 0,
                "character": 2
            }
        }
    }
}

The code tested with is src/main.rs from a fresh cargo new.

kak-lsp version: kakoune-lsp/kakoune-lsp@d5e39a9
rust-analyzer version: rust-analyzer cbbb7f351 2021-08-25 dev

@Veykril Veykril added the S-actionable Someone could pick this issue up and work on it right now label Aug 25, 2021
@vsrs
Copy link
Contributor

vsrs commented Oct 26, 2021

The issue also messes QuickInfo in Visual Studio (#8729), I'm going to fix it.

bors bot added a commit that referenced this issue Oct 29, 2021
10662: Fix Plaintext textDocument/hover r=Veykril a=vsrs

Relates to #10028

Note: the PR corrects only invalid content kind, not formatting.

Co-authored-by: vsrs <[email protected]>
@Veykril Veykril added C-bug Category: bug A-hover hover feature labels Jan 19, 2023
@bors bors closed this as completed in ce67dea Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-hover hover feature C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants