aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-02-13 05:19:33 -0800
committerGitHub <noreply@github.com>2025-02-13 05:19:33 -0800
commit375847fb334baf7a1c8b01ac5c4451edb426b6b8 (patch)
treeff3ec8f57822ed4355288ac6ffdcb2b73ab7862a /runtime/lua
parentc374f264305f0cae77b13eba99db027aa7a6cb07 (diff)
parent2df68d3696c0e48a9b6c23b654754942504dce34 (diff)
downloadrneovim-375847fb334baf7a1c8b01ac5c4451edb426b6b8.tar.gz
rneovim-375847fb334baf7a1c8b01ac5c4451edb426b6b8.tar.bz2
rneovim-375847fb334baf7a1c8b01ac5c4451edb426b6b8.zip
Merge #32426 fix(lsp): reset active request when reporting an error
Diffstat (limited to 'runtime/lua')
-rw-r--r--runtime/lua/vim/lsp/semantic_tokens.lua18
-rw-r--r--runtime/lua/vim/lsp/util.lua1
2 files changed, 11 insertions, 8 deletions
diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua
index 619f7f1110..5f60b732de 100644
--- a/runtime/lua/vim/lsp/semantic_tokens.lua
+++ b/runtime/lua/vim/lsp/semantic_tokens.lua
@@ -288,15 +288,23 @@ function STHighlighter:send_request()
method = method .. '/delta'
params.previousResultId = current_result.result_id
end
+ ---@param response? lsp.SemanticTokens|lsp.SemanticTokensDelta
local success, request_id = client:request(method, params, function(err, response, ctx)
-- look client up again using ctx.client_id instead of using a captured
-- client object
local c = vim.lsp.get_client_by_id(ctx.client_id)
local bufnr = assert(ctx.bufnr)
local highlighter = STHighlighter.active[bufnr]
- if not err and c and highlighter then
- coroutine.wrap(STHighlighter.process_response)(highlighter, response, c, version)
+ if not (c and highlighter) then
+ return
end
+
+ if err or not response then
+ highlighter.client_state[c.id].active_request = {}
+ return
+ end
+
+ coroutine.wrap(STHighlighter.process_response)(highlighter, response, c, version)
end, self.bufnr)
if success then
@@ -331,12 +339,6 @@ function STHighlighter:process_response(response, client, version)
return
end
- -- skip nil responses
- if response == nil then
- state.active_request = {}
- return
- end
-
if not api.nvim_buf_is_valid(self.bufnr) then
return
end
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ba519614c0..9e84e27205 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -2218,6 +2218,7 @@ function M._refresh(method, opts)
M._cancel_requests({
bufnr = bufnr,
clients = clients,
+ method = method,
type = 'pending',
})
for _, client in ipairs(clients) do