feat(lsp): support workspace/foldingRange/refresh #41780

Problem:
Servers cannot request refreshing stale LSP folding ranges after a
project-wide change.

Solution:
Advertise `workspace.foldingRange.refreshSupport` and re-request folding
ranges for active buffers when handling `workspace/foldingRange/refresh`.

AI-assisted
This commit is contained in:
Volodymyr Chernetskyi
2026-09-09 14:45:10 +02:00
committed by GitHub
parent 0a844adc13
commit 8e0045f43a
5 changed files with 57 additions and 1 deletions

View File

@@ -289,6 +289,26 @@ function State:foldclose(kind, winid)
end)
end
--- |lsp-handler| for the method `workspace/foldingRange/refresh`
---
--- Refresh requests are sent by the server to indicate a project-wide change
--- that requires all folding ranges to be re-requested by the client.
---@param ctx lsp.HandlerContext
---@internal
function M.on_refresh(err, _, ctx)
if err then
return vim.NIL
end
for _, state in pairs(State.active) do
if state.client_state[ctx.client_id] then
state:refresh(ctx.client_id)
end
end
return vim.NIL
end
---@param kind lsp.FoldingRangeKind
---@param winid? integer
function M.foldclose(kind, winid)