From 88c5f6ce5628de63c2e28624cf48b6c2055576c2 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 14 Aug 2022 13:29:06 +1000 Subject: [PATCH] fix(#1503): focus last win before close --- lua/nvim-tree/view.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index dbe880ffe43..fb153de7b0d 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -188,11 +188,11 @@ function M.close() local current_win = a.nvim_get_current_win() for _, win in pairs(a.nvim_list_wins()) do if tree_win ~= win and a.nvim_win_get_config(win).relative == "" then - a.nvim_win_close(tree_win, true) local prev_win = vim.fn.winnr "#" -- this tab only if tree_win == current_win and prev_win > 0 then a.nvim_set_current_win(vim.fn.win_getid(prev_win)) end + a.nvim_win_close(tree_win, true) events._dispatch_on_tree_close() return end