fix: "Invalid buffer id" on closing nvim-tree window (#3129)

fix: invalid buffer issue

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Christoph 2025-05-18 06:35:59 +02:00 committed by GitHub
parent e4cd856ebf
commit 25d16aab7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -242,6 +242,9 @@ local function setup_autocommands(opts)
pattern = "*", pattern = "*",
---@param ev vim.api.keyset.create_autocmd.callback_args ---@param ev vim.api.keyset.create_autocmd.callback_args
callback = function(ev) callback = function(ev)
if not vim.api.nvim_buf_is_valid(ev.buf) then
return
end
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
require("nvim-tree.events")._dispatch_on_tree_close() require("nvim-tree.events")._dispatch_on_tree_close()
end end