mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
fix(lsp): treat nil inlay hint result as empty array (#35458)
`gopls` seems to send a nil result when there are no inlay hints for the buffer. [The protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint) allows for the server to send an array or nil, and it isn't clear what nil should represent. I think it's reasonable to treat it as an empty array though.
This commit is contained in:
committed by
GitHub
parent
6018aed92f
commit
1f63735f17
@@ -44,9 +44,9 @@ function M.on_inlayhint(err, result, ctx)
|
||||
return
|
||||
end
|
||||
local bufnr = assert(ctx.bufnr)
|
||||
|
||||
if
|
||||
util.buf_versions[bufnr] ~= ctx.version
|
||||
or not result
|
||||
or not api.nvim_buf_is_loaded(bufnr)
|
||||
or not bufstates[bufnr].enabled
|
||||
then
|
||||
@@ -61,6 +61,9 @@ function M.on_inlayhint(err, result, ctx)
|
||||
local client_hints = bufstate.client_hints
|
||||
local client = assert(vim.lsp.get_client_by_id(client_id))
|
||||
|
||||
-- If there's no error but the result is nil, clear existing hints.
|
||||
result = result or {}
|
||||
|
||||
local new_lnum_hints = vim.defaulttable()
|
||||
local num_unprocessed = #result
|
||||
if num_unprocessed == 0 then
|
||||
|
||||
Reference in New Issue
Block a user