Merge #32426 fix(lsp): reset active request when reporting an error

This commit is contained in:
Justin M. Keyes
2025-02-13 05:19:33 -08:00
committed by GitHub
2 changed files with 11 additions and 8 deletions

View File

@@ -288,15 +288,23 @@ function STHighlighter:send_request()
method = method .. '/delta' method = method .. '/delta'
params.previousResultId = current_result.result_id params.previousResultId = current_result.result_id
end end
---@param response? lsp.SemanticTokens|lsp.SemanticTokensDelta
local success, request_id = client:request(method, params, function(err, response, ctx) 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 -- look client up again using ctx.client_id instead of using a captured
-- client object -- client object
local c = vim.lsp.get_client_by_id(ctx.client_id) local c = vim.lsp.get_client_by_id(ctx.client_id)
local bufnr = assert(ctx.bufnr) local bufnr = assert(ctx.bufnr)
local highlighter = STHighlighter.active[bufnr] local highlighter = STHighlighter.active[bufnr]
if not err and c and highlighter then if not (c and highlighter) then
coroutine.wrap(STHighlighter.process_response)(highlighter, response, c, version) return
end 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) end, self.bufnr)
if success then if success then
@@ -331,12 +339,6 @@ function STHighlighter:process_response(response, client, version)
return return
end end
-- skip nil responses
if response == nil then
state.active_request = {}
return
end
if not api.nvim_buf_is_valid(self.bufnr) then if not api.nvim_buf_is_valid(self.bufnr) then
return return
end end

View File

@@ -2218,6 +2218,7 @@ function M._refresh(method, opts)
M._cancel_requests({ M._cancel_requests({
bufnr = bufnr, bufnr = bufnr,
clients = clients, clients = clients,
method = method,
type = 'pending', type = 'pending',
}) })
for _, client in ipairs(clients) do for _, client in ipairs(clients) do