mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
fix(vim.lsp.inlay_hint): requesting inlay_hints even when disabled #32999
Problem:
Nvim needlessly requests inlay_hints even if they are disabled for a given buffer.
Solution:
Add the missing `enabled` check in `on_refresh`.
Rest of the code has this check already so that's the only needed one to fix this.
(cherry picked from commit 49756ebc70
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
d2dd403693
commit
9056c01a95
@@ -297,6 +297,50 @@ int main() {
|
||||
end)
|
||||
)
|
||||
end)
|
||||
|
||||
it('does not request hints from lsp when disabled', function()
|
||||
exec_lua(function()
|
||||
_G.server2 = _G._create_server({
|
||||
capabilities = {
|
||||
inlayHintProvider = true,
|
||||
},
|
||||
handlers = {
|
||||
['textDocument/inlayHint'] = function(_, _, callback)
|
||||
_G.got_inlay_hint_request = true
|
||||
callback(nil, {})
|
||||
end,
|
||||
},
|
||||
})
|
||||
_G.client2 = vim.lsp.start({ name = 'dummy2', cmd = _G.server2.cmd })
|
||||
end)
|
||||
|
||||
local function was_request_sent()
|
||||
return exec_lua(function()
|
||||
return _G.got_inlay_hint_request == true
|
||||
end)
|
||||
end
|
||||
|
||||
eq(false, was_request_sent())
|
||||
|
||||
exec_lua(function()
|
||||
vim.lsp.inlay_hint.get()
|
||||
end)
|
||||
|
||||
eq(false, was_request_sent())
|
||||
|
||||
exec_lua(function()
|
||||
vim.lsp.inlay_hint.enable(false, { bufnr = bufnr })
|
||||
vim.lsp.inlay_hint.get()
|
||||
end)
|
||||
|
||||
eq(false, was_request_sent())
|
||||
|
||||
exec_lua(function()
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end)
|
||||
|
||||
eq(true, was_request_sent())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user