fix(lsp): don't treat MarkedString[] with language id as empty #35518

Problem:
Hover response of MarkedString[] where the first element contains a
language identifier treated as empty.

Solution:
Fix empty check to handle case of MarkedString[] where the first element
is a pair of a language and value.
This commit is contained in:
Robert Muir
2025-08-27 21:51:30 -04:00
committed by GitHub
parent 2ac00f1350
commit 729111d3a3
2 changed files with 45 additions and 2 deletions

View File

@@ -7139,5 +7139,33 @@ describe('LSP', function()
eq('Empty hover response', n.exec_capture('lua vim.lsp.buf.hover()'))
end)
it('treats markedstring array as not empty', function()
exec_lua(create_server_definition)
exec_lua(function()
local server = _G._create_server({
capabilities = {
hoverProvider = true,
},
handlers = {
['textDocument/hover'] = function(_, _, callback)
local res = {
contents = {
{
language = 'java',
value = 'Example',
},
'doc comment',
},
}
callback(nil, res)
end,
},
})
vim.lsp.start({ name = 'dummy', cmd = server.cmd })
end)
eq('', n.exec_capture('lua vim.lsp.buf.hover()'))
end)
end)
end)