zed
zed copied to clipboard
Add missing newlines in hover tooltips
fix #10511
Release Notes:
- N/A
Warnings | |
---|---|
:warning: |
This PR is missing release notes. Please add a "Release Notes" section that describes the change:
If your change is not user-facing, you can use "N/A" for the entry:
|
Generated by :no_entry_sign: dangerJS against 2b64cb4ec5f35d8c6dd36795a0ab84f440e0d00f
@mrnugget when enter metadata block, start new parser for content in block. Is this an acceptable method?
@mrnugget when enter metadata block, start new parser for content in block. Is this an acceptable method?
Hmmm, I'm a bit skeptical of recursion here. Do you have a specific bit of Markdown to reproduce the issue? I think we at least need that.
just in any c/cpp file with clangd lsp. mouse hover any function name. currently display is oddly.
Yes, but can you get the exact Markdown here, so we can look at it and possibly write a test case? If you do RUST_LOG=lsp=trace cargo run ~/cpp-project
you should be able to see the raw JSON returned by clangd
and that should include the Markdown.
2024-04-16T15:58:00+08:00 TRACE lsp] incoming message: {"id":4,"jsonrpc":"2.0","result":{"contents":{"kind":"markdown","value":"### function `search` \n\n---\n→ `void` \nParameters: \n- `TrieNode * flag (aka struct TrieNode *)`\n- `char * word`\n\n---\n```cpp\nvoid search(TrieNode *flag, char *word)\n```"},"range":{"end":{"character":8,"line":230},"start":{"character":2,"line":230}}}}
Okay, so the markdown looks like this:
### function `search`
---
→ `void`
Parameters:
- `TrieNode * flag (aka struct TrieNode *)`
- `char * word`
---
```cpp
void search(TrieNode *flag, char *word)
```
That makes me wonder: aren't the ---
just supposed to be dividers? Like, if I put a ---
in the next line here
then it renders as a <hr>
I think. So should we handle that?
Okay, so the markdown looks like this:
### function `search` --- → `void` Parameters: - `TrieNode * flag (aka struct TrieNode *)` - `char * word` --- ```cpp void search(TrieNode *flag, char *word)
That makes me wonder: aren't the `---` just supposed to be dividers? Like, if I put a `---` in the next line here then it renders as a `<hr>` I think. So should we handle that?
Hmm I think there are two problems which we will run into when rendering dividers:
- It looks like our markdown parser dependency (pulldown_cmark) does not pickup dividers if there is no line break before and after the
---
, see https://www.markdownguide.org/basic-syntax/#horizontal-rule-best-practices. Github is able to render that though - The markdown crate renders everything into an
InteractiveText
element, which does not support inserting elements other than text. We could 'split' up blocks here and render dividers, however at this point it would probably make the most sense to combine thelanguage
markdown implementation with themarkdown_preview
markdown implementation (which does support lists, tables, dividers, etc.)
In markdown, start ---
and end with ---
is an extentsion named markdown yaml metadata block, and there also can be start +++
with end +++
. this is not dividers
In markdown, start
---
and end with---
is an extentsion named markdown yaml metadata block
Isn't that YAML frontmatter? YAML frontmatter is supposed to only show up at the start of a text (see here) and "must take the form of valid YAML set between triple-dashed lines".
In this case it doesn't look like that's YAML between the ---
.
Neovim also renders it as dividers:
With this being the Markdown:
### instance-method `format`
---
→ `void`
Parameters:
- `const int &`
- `const std::tm &`
- `int & dest`
---
```cpp
// In my_formatter_flag
public: void format(const int &, const std::tm &, int &dest)
```
Closing this in favor of https://github.com/zed-industries/zed/pull/10606