neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 1de77c608fa99760a0073db71f687e618f539020
parent 8ede293b8ad2408bfa4b47d18128fcb14ef61fa6
Author: Tristan Knight <admin@snappeh.com>
Date:   Mon,  1 Dec 2025 17:51:04 +0000

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.
Diffstat:
Mruntime/lua/vim/lsp/semantic_tokens.lua | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -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()