diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 1791e9f33c9..32df150c7e0 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -1576,7 +1576,7 @@ Specify minimum notification level, uses the values from |vim.log.levels| `ERROR`: hard errors e.g. failure to read from the file system. `WARNING`: non-fatal errors e.g. unable to system open a file. `INFO:` information only e.g. file copy path confirmation. -`DEBUG:` not used. +`DEBUG:` information for troubleshooting, e.g. failures in some window closing operations. *nvim-tree.notify.absolute_path* Whether to use absolute paths or item names in fs action notifications. diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index f30eb2720a4..315da3d0d19 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -1,6 +1,7 @@ local events = require "nvim-tree.events" local utils = require "nvim-tree.utils" local log = require "nvim-tree.log" +local notify = require "nvim-tree.notify" ---@class OpenInWinOpts ---@field hijack_current_buf boolean|nil default true @@ -227,7 +228,11 @@ local function close(tabpage) vim.api.nvim_set_current_win(vim.fn.win_getid(prev_win)) end if vim.api.nvim_win_is_valid(tree_win or 0) then - vim.api.nvim_win_close(tree_win or 0, true) + local success, error = pcall(vim.api.nvim_win_close, tree_win or 0, true) + if not success then + notify.debug("Failed to close window: " .. error) + return + end end events._dispatch_on_tree_close() return