aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorJaehwang Jung <tomtomjhj@gmail.com>2024-03-23 01:46:01 +0900
committerGitHub <noreply@github.com>2024-03-22 17:46:01 +0100
commit849d82b80b8584fe7918bffc6480f0ec0fda9b9b (patch)
treeacb9a1cb36fce2f84db9ff10decc5e113c449140 /runtime/lua/vim
parentdc110cba3c0d48d7c9dbb91900f8be0cf6cf0c9b (diff)
downloadrneovim-849d82b80b8584fe7918bffc6480f0ec0fda9b9b.tar.gz
rneovim-849d82b80b8584fe7918bffc6480f0ec0fda9b9b.tar.bz2
rneovim-849d82b80b8584fe7918bffc6480f0ec0fda9b9b.zip
fix(lsp): handle stale bufnr on LspRequest autocmd trigger (#27981)
continuation of https://github.com/neovim/neovim/pull/24013
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/client.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua
index d48be131f3..b06fab7319 100644
--- a/runtime/lua/vim/lsp/client.lua
+++ b/runtime/lua/vim/lsp/client.lua
@@ -693,7 +693,7 @@ function Client:_request(method, params, handler, bufnr)
local request = { type = 'pending', bufnr = bufnr, method = method }
self.requests[request_id] = request
api.nvim_exec_autocmds('LspRequest', {
- buffer = bufnr,
+ buffer = api.nvim_buf_is_valid(bufnr) and bufnr or nil,
modeline = false,
data = { client_id = self.id, request_id = request_id, request = request },
})
@@ -804,7 +804,7 @@ function Client:_cancel_request(id)
if request and request.type == 'pending' then
request.type = 'cancel'
api.nvim_exec_autocmds('LspRequest', {
- buffer = request.bufnr,
+ buffer = api.nvim_buf_is_valid(request.bufnr) and request.bufnr or nil,
modeline = false,
data = { client_id = self.id, request_id = id, request = request },
})