aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorYi Ming <ofseed@foxmail.com>2025-08-25 09:59:56 +0800
committerGitHub <noreply@github.com>2025-08-24 18:59:56 -0700
commit42f244bf18a135dcbc983f7e0e0387c43c4dc664 (patch)
treeb529d00642da30d682ba2ea9589e4e8ca6f86085 /runtime/lua/vim
parentbccec33f5a011fac7f0a90260c72c2ac2f4c334f (diff)
downloadrneovim-42f244bf18a135dcbc983f7e0e0387c43c4dc664.tar.gz
rneovim-42f244bf18a135dcbc983f7e0e0387c43c4dc664.tar.bz2
rneovim-42f244bf18a135dcbc983f7e0e0387c43c4dc664.zip
fix(lsp): check whether buffer is valid when scheduled #35461
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/_folding_range.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/_folding_range.lua b/runtime/lua/vim/lsp/_folding_range.lua
index 6997ec2771..7f23eb3cc9 100644
--- a/runtime/lua/vim/lsp/_folding_range.lua
+++ b/runtime/lua/vim/lsp/_folding_range.lua
@@ -265,7 +265,7 @@ end
---@param client_id integer
function State:on_attach(client_id)
- self.client_state = {}
+ self.client_state[client_id] = {}
self:refresh(vim.lsp.get_client_by_id(client_id))
end
@@ -344,7 +344,9 @@ function M.foldexpr(lnum)
if not vim.lsp._capability.is_enabled('folding_range', { bufnr = bufnr }) then
-- `foldexpr` lead to a textlock, so any further operations need to be scheduled.
vim.schedule(function()
- vim.lsp._capability.enable('folding_range', true, { bufnr = bufnr })
+ if api.nvim_buf_is_valid(bufnr) then
+ vim.lsp._capability.enable('folding_range', true, { bufnr = bufnr })
+ end
end)
end