mirror of
https://github.com/neovim/neovim.git
synced 2026-08-31 03:13:48 +00:00
fix(lsp): skip codelens refresh redraw for deleted buffer #39193
Problem: After on_refresh() sends a textDocument/codeLens request, the buffer may be deleted before the response arrives. The response callback then tries to redraw that deleted buffer and raises Invalid buffer id error. Solution: Check buffer validity before redrawing. AI-assisted: Codex Co-authored-by: Yi Ming <ofseed@foxmail.com>
This commit is contained in:
@@ -500,8 +500,10 @@ function M.on_refresh(err, _, ctx)
|
||||
-- Do nothing if a request is already scheduled.
|
||||
if not provider.timer then
|
||||
provider:request(client_id, function()
|
||||
provider.row_version = {}
|
||||
vim.api.nvim__redraw({ buf = bufnr, valid = true, flush = false })
|
||||
if api.nvim_buf_is_valid(bufnr) then
|
||||
provider.row_version = {}
|
||||
vim.api.nvim__redraw({ buf = bufnr, valid = true, flush = false })
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user