emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 873 forks source link

lsp-javascript typescript typescript-language-server > 1.2.0 hover -> nothing in echo area #3966

Open ghost opened 1 year ago

ghost commented 1 year ago

Thank you for the bug report

Bug description

When using a version of typescript-language-server above 1.2.0, when hovering a symbol, it is not shown in the ~minibuffer~ echo area.

I've done some debugging, and found a difference in the response w.r.t. textDocument/hover:

With @1.2.0

[Trace - 05:03:56 ] Received response 'textDocument/hover - (284)' in 28ms.
Result: {
  "contents": [
    {
      "language": "typescript",
      "value": "(alias) interface CaptchaConfig\nimport CaptchaConfig"
    },
    ""
  ],
  "range": {
    "start": {
      "line": 11,
      "character": 11
    },
    "end": {
      "line": 11,
      "character": 24
    }
  }
}

With @3.3.0

[Trace - 05:06:41 ] Received response 'textDocument/hover - (333)' in 67ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "\n```typescript\n(alias) interface CaptchaConfig\nimport CaptchaConfig\n```\n"
  },
  "range": {
    "start": {
      "line": 11,
      "character": 11
    },
    "end": {
      "line": 11,
      "character": 24
    }
  }
}

So the data structure for content is quite different, probably causing it not to display at all.

Newer version also is in markdown format -> maybe this is a setting?

Steps to reproduce

Install a version of typescript-language-server above 1.2.0, for instance yarn global add typescript-language-server@3.3.0

Open typescript project, hover a symbol.

Expected behavior

To get the info returned in hover action shown in the echo area.

Which Language Server did you use?

lsp-javascript / ts-ls / typescript-language-server

OS

Linux

Error callstack

No response

Anything else?

No response

ghost commented 1 year ago

Done some more debugging.

Setting 'lsp-eldoc-render-all to t helps.

Due to: https://github.com/emacs-lsp/lsp-mode/blob/e6293251a65554fa23f87d0e883d121b4f0aed4e/lsp-mode.el#L5487-L5493

Maybe this logic can be extended.

"Tends to be quite long" -> Maybe test for this to be true?

Just displaying the first line in this case completely fails since the string starts with a line break. A minimal improvement could strip/skip leading line breaks ('lsp--handle-rendered-for-echo-area)