fix: safely close last tree window (#2913)
fix: safely close tree window with pcall and debug logging Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
cd9c6db77f
commit
bd4881660b
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user