From 25d16aab7d29ca940a9feb92e6bb734697417009 Mon Sep 17 00:00:00 2001 From: Christoph <52382992+chrishrb@users.noreply.github.com> Date: Sun, 18 May 2025 06:35:59 +0200 Subject: [PATCH] fix: "Invalid buffer id" on closing nvim-tree window (#3129) fix: invalid buffer issue Co-authored-by: Alexander Courtis --- lua/nvim-tree.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 3e8c04b7..c4cdbcf7 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -242,6 +242,9 @@ local function setup_autocommands(opts) pattern = "*", ---@param ev vim.api.keyset.create_autocmd.callback_args 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 require("nvim-tree.events")._dispatch_on_tree_close() end