aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp
diff options
context:
space:
mode:
authorYi Ming <ofseed@foxmail.com>2024-04-10 18:27:37 +0800
committerGitHub <noreply@github.com>2024-04-10 12:27:37 +0200
commit1dacf2ecee36e2abd490df2ad5f9c24fa73205b7 (patch)
treea09744184852483e2f944d1297c07cf0880fd773 /runtime/lua/vim/lsp
parentb95b6ed9753da8f157d3ba34408c4c2e0de9d744 (diff)
downloadrneovim-1dacf2ecee36e2abd490df2ad5f9c24fa73205b7.tar.gz
rneovim-1dacf2ecee36e2abd490df2ad5f9c24fa73205b7.tar.bz2
rneovim-1dacf2ecee36e2abd490df2ad5f9c24fa73205b7.zip
fix(lsp): prevent code-lens refresh from becoming a permanent no-op (#28228)
To avoid repeatedly requesting a buffer multiple times before a request is completed, the current implementation puts the requested buffer into the active_refreshes table before requesting. But since we only remove the buffer from active_refreshes in the lsp-handler of textDocument/codeLens, this will cause if the user sends a request that cannot trigger lsp-handler (for example, if there is an LSP server attached to the current buffer, and especially when the user creates an autocmd which performs vim.lsp.codelens.refresh after the BufEnter event is triggered like in the document example), this buffer will be put into active_refreshes, and there is no way to remove it, which will result in all subsequent vim.lsp.codelens.refresh not requesting textDocument/codeLens.
Diffstat (limited to 'runtime/lua/vim/lsp')
-rw-r--r--runtime/lua/vim/lsp/codelens.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua
index 90ca83cd59..a2a0c15b93 100644
--- a/runtime/lua/vim/lsp/codelens.lua
+++ b/runtime/lua/vim/lsp/codelens.lua
@@ -231,7 +231,7 @@ local function resolve_lenses(lenses, bufnr, client_id, callback)
countdown()
else
assert(client)
- client.request('codeLens/resolve', lens, function(_, result)
+ client.request(ms.codeLens_resolve, lens, function(_, result)
if api.nvim_buf_is_loaded(bufnr) and result and result.command then
lens.command = result.command
-- Eager display to have some sort of incremental feedback
@@ -306,7 +306,11 @@ function M.refresh(opts)
textDocument = util.make_text_document_params(buf),
}
active_refreshes[buf] = true
- vim.lsp.buf_request(buf, ms.textDocument_codeLens, params, M.on_codelens)
+
+ local request_ids = vim.lsp.buf_request(buf, ms.textDocument_codeLens, params, M.on_codelens)
+ if vim.tbl_isempty(request_ids) then
+ active_refreshes[buf] = nil
+ end
end
end
end