Skip to content

Commit 42f244b

Browse files
authored
fix(lsp): check whether buffer is valid when scheduled neovim#35461
1 parent bccec33 commit 42f244b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

runtime/lua/vim/lsp/_folding_range.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ end
265265

266266
---@param client_id integer
267267
function State:on_attach(client_id)
268-
self.client_state = {}
268+
self.client_state[client_id] = {}
269269
self:refresh(vim.lsp.get_client_by_id(client_id))
270270
end
271271

@@ -344,7 +344,9 @@ function M.foldexpr(lnum)
344344
if not vim.lsp._capability.is_enabled('folding_range', { bufnr = bufnr }) then
345345
-- `foldexpr` lead to a textlock, so any further operations need to be scheduled.
346346
vim.schedule(function()
347-
vim.lsp._capability.enable('folding_range', true, { bufnr = bufnr })
347+
if api.nvim_buf_is_valid(bufnr) then
348+
vim.lsp._capability.enable('folding_range', true, { bufnr = bufnr })
349+
end
348350
end)
349351
end
350352

0 commit comments

Comments
 (0)