mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 17:12:40 +00:00
fix(lsp): handle nil request in semantic tokens #36780
Allow the `request` parameter in `tokens_to_ranges` to be `nil` and update version checking logic accordingly. This prevents errors when the request is not present and improves robustness of semantic token handling.
This commit is contained in:
@@ -80,7 +80,7 @@ end
|
||||
---@param data integer[]
|
||||
---@param bufnr integer
|
||||
---@param client vim.lsp.Client
|
||||
---@param request STActiveRequest
|
||||
---@param request STActiveRequest | nil
|
||||
---@return STTokenRange[]
|
||||
local function tokens_to_ranges(data, bufnr, client, request)
|
||||
local legend = client.server_capabilities.semanticTokensProvider.legend
|
||||
@@ -108,7 +108,7 @@ local function tokens_to_ranges(data, bufnr, client, request)
|
||||
vim.schedule(function()
|
||||
coroutine.resume(co, util.buf_versions[bufnr])
|
||||
end)
|
||||
if request.version ~= coroutine.yield() then
|
||||
if not request or request.version ~= coroutine.yield() then
|
||||
-- request became stale since the last time the coroutine ran.
|
||||
-- abandon it by yielding without a way to resume
|
||||
coroutine.yield()
|
||||
|
||||
Reference in New Issue
Block a user