mirror of
https://github.com/neovim/neovim.git
synced 2026-07-09 19:09:39 +00:00
fix(lsp): refresh document-pull buffers on workspace/diagnostic/refresh #40623
When a server supports both document and workspace pull diagnostics, `on_refresh` only dispatched a `workspace/diagnostic` request. The workspace response handler skips buffers with `pull_kind == "document"` (i.e. all buffers opened by the user), so their diagnostics went stale until the next `didChange` or `didOpen` event. Change `on_refresh` to always refresh document-pull buffers via `textDocument/diagnostic`, regardless of whether the server also supports workspace diagnostics. This ensures that opened buffers see updated diagnostics (e.g. after a save triggers an external tool like PHPStan) without requiring the user to re-enter insert mode.
This commit is contained in:
@@ -405,13 +405,16 @@ function M.on_refresh(err, _, ctx)
|
||||
end
|
||||
if client:supports_method('workspace/diagnostic') then
|
||||
M._workspace_diagnostics({ client_id = ctx.client_id })
|
||||
else
|
||||
for bufnr in pairs(client.attached_buffers or {}) do
|
||||
local provider = Diagnostics.active[bufnr]
|
||||
local state = provider and provider.client_state[ctx.client_id]
|
||||
if state and state.pull_kind == 'document' then
|
||||
provider:refresh(ctx.client_id)
|
||||
end
|
||||
end
|
||||
|
||||
-- Always refresh document-pull buffers. Workspace diagnostics only cover
|
||||
-- buffers with pull_kind == 'workspace', so open buffers must be refreshed
|
||||
-- individually or their diagnostics go stale until the next didChange.
|
||||
for bufnr in pairs(client.attached_buffers or {}) do
|
||||
local provider = Diagnostics.active[bufnr]
|
||||
local state = provider and provider.client_state[ctx.client_id]
|
||||
if state and state.pull_kind == 'document' then
|
||||
provider:refresh(ctx.client_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user