mirror of
https://github.com/neovim/neovim.git
synced 2026-08-02 05:39:12 +00:00
fix(lsp): incorrect rendering of markdown codeblock #40861
Problem:
LSP hover erroneously drops blank lines before a 4-space-indented
codeblock, which is not valid Markdown. This causes incorrect parsing
and wrong display.
Solution:
Fix `split_lines` so that it doesn't drop the blank line just before
a 4-space-indented codeblock.
fix https://github.com/neovim/neovim/issues/40860
(cherry picked from commit 317c5ddda6)
This commit is contained in:
committed by
github-actions[bot]
parent
37d7b11bc1
commit
ba2ea67a1f
@@ -1209,7 +1209,7 @@ describe('vim.lsp.util', function()
|
||||
local r = exec_lua(function()
|
||||
local hover_data = {
|
||||
kind = 'markdown',
|
||||
value = '```lua\nfunction vim.api.nvim_buf_attach(buffer: integer, send_buffer: boolean, opts: vim.api.keyset.buf_attach)\n -> boolean\n```\n\n---\n\n Activates buffer-update events. Example:\n\n\n\n ```lua\n events = {}\n vim.api.nvim_buf_attach(0, false, {\n on_lines = function(...)\n table.insert(events, {...})\n end,\n })\n ```\n\n\n @see `nvim_buf_detach()`\n @see `api-buffer-updates-lua`\n@*param* `buffer` — Buffer handle, or 0 for current buffer\n\n\n\n@*param* `send_buffer` — True if whole buffer.\n Else the first notification will be `nvim_buf_changedtick_event`.\n\n\n@*param* `opts` — Optional parameters.\n\n - on_lines: Lua callback. Args:\n - the string "lines"\n - buffer handle\n - b:changedtick\n@*return* — False if foo;\n\n otherwise True.\n\n@see foo\n@see bar\n\n',
|
||||
value = '```lua\nfunction vim.api.nvim_buf_attach(buffer: integer, send_buffer: boolean, opts: vim.api.keyset.buf_attach)\n -> boolean\n```\n\n---\n\n Activates buffer-update events. Example:\n\n\n\n ```lua\n events = {}\n vim.api.nvim_buf_attach(0, false, {\n on_lines = function(...)\n table.insert(events, {...})\n end,\n })\n ```\n\n\n @see `nvim_buf_detach()`\n @see `api-buffer-updates-lua`\n@*param* `buffer` — Buffer handle, or 0 for current buffer\n\n\n\n@*param* `send_buffer` — True if whole buffer.\n Else the first notification will be `nvim_buf_changedtick_event`.\n\n\n@*param* `opts` — Optional parameters.\n\n - on_lines: Lua callback. Args:\n - the string "lines"\n - buffer handle\n - b:changedtick\n@*return* — False if foo;\n\n otherwise True.\n\n@see foo\n@see bar\n\nExample:\n\n iex> params = %{title: "", topics: []}\n\n iex> changeset.changes[:topics]\n',
|
||||
}
|
||||
return vim.lsp.util.convert_input_to_markdown_lines(hover_data)
|
||||
end)
|
||||
@@ -1256,6 +1256,12 @@ describe('vim.lsp.util', function()
|
||||
' otherwise True.',
|
||||
'@see foo',
|
||||
'@see bar',
|
||||
-- Blank line preceding a 4-space-indented codeblock is required, per Markdown spec. #40860
|
||||
'Example:',
|
||||
'',
|
||||
' iex> params = %{title: "", topics: []}',
|
||||
'',
|
||||
' iex> changeset.changes[:topics]',
|
||||
}
|
||||
eq(expected, r)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user