diff options
| author | notomo <18519692+notomo@users.noreply.github.com> | 2025-09-09 09:52:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-08 17:52:25 -0700 |
| commit | bbfcde3ab20e0a490c9cce9afce97412cb1fde32 (patch) | |
| tree | 96daa42a8939771df508c8f2493543701846d483 /runtime/syntax/python.vim | |
| parent | a7b8102f20d5f36c63ec747b40c44cff100da8e3 (diff) | |
| download | rneovim-bbfcde3ab20e0a490c9cce9afce97412cb1fde32.tar.gz rneovim-bbfcde3ab20e0a490c9cce9afce97412cb1fde32.tar.bz2 rneovim-bbfcde3ab20e0a490c9cce9afce97412cb1fde32.zip | |
fix(lsp): check if buffer is valid in scheduled client:on_attach() #35672
Problem:
lsp._capability.is_enabled() can raise error if buffer is invalid in client:on_attach().
- error
```
./build/bin/nvim --clean --headless +"source ./minimal.lua"
vim.schedule callback: ...omo/workspace/neovim/runtime/lua/vim/lsp/_capability.lua:209: scoped variable: Invalid buffer id: 2
stack traceback:
[C]: in function '__index'
...omo/workspace/neovim/runtime/lua/vim/lsp/_capability.lua:209: in function 'is_enabled'
...e/notomo/workspace/neovim/runtime/lua/vim/lsp/client.lua:1108: in function <...e/notomo/workspace/neovim/runtime/lua/vim/lsp/client.lua:1101>
```
- reproduction minimal.lua
```lua
vim.opt.runtimepath:append("/path/to/nvim-lspconfig/")
vim.lsp.enable("lua_ls")
vim.cmd.tabedit("runtime/lua/vim/_defaults.lua")
vim.api.nvim_create_autocmd({ "LspAttach" }, {
group = vim.api.nvim_create_augroup("test", {}),
callback = function()
vim.cmd.tabedit("runtime/lua/vim/_defaults.lua")
local bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_delete(bufnr, { force = true })
end,
})
```
Solution:
Check whether buffer is valid.
Diffstat (limited to 'runtime/syntax/python.vim')
0 files changed, 0 insertions, 0 deletions